Adding formulas to buttons

Create workflows and customization by combining buttons and formulas

Updated over a week ago

Inside this article

⭐ Coda Tips!

Example 1 - Personalized to-dos

This first example uses the User( ) formula to create a collaborative to-do list. 

Here's how it's set up. Let's start with the first button Add To Do for Al:

  1. Name: "Add To Do"

  2. Label:  ="Add To Do for " + User().Split(" ").First()

How this formula works: This formula pulls from the currently logged in user with the User() formula, and then using Split() and First() to only pull the user's first name.

3. Action: Add Row. We then choose to add the row to the Task List table and pull the User's name using the User() formula again:


4. Open Row For Editing: We've toggled this on so that the row modal can act like a form entry

Now, let's take a look at the second button, Make Al's Stuff Done:

  1. Name: "Mark To Dos Done"

  2. Label: ="Make " + User().Split(" ").First() + "'s Stuff Done"

  3. Action: Modify rows. We still choose the Task List table as the target and a custom filter by user with the result of marking the Done column as true:

4. This button has one more setting, Disable If because we don't always want it to be active. In this case, we want it disabled if the person who is logged in doesn't have tasks or if all the tasks are marked as done already. Here's the formula:

Example 2 - Adding new contacts

Buttons can also be used to act like an entry form for your databases like we see below for updating a customer contact record:

In this example, we only have one button, Add New Contact. Let's see what's under the hood:

  1. Name: "Lead Button"

  2. Label: "Add New Contact"

  3. Action: Add Row - our target is the Contacts table, and we want the logged in user to be the Account Owner (so we'll use the User() formula again), and we want the Status to be set to "Not Contacted" as a default:

4. Open Row For Editing - Toggled on so that the person entering can add further details about the lead. 

Example 3 - Logging updates

Updating status can be a bit of a chore so these buttons are designed to make it streamlined and a one stop shop:

Here we are using buttons as a column format. Let's take a look at the set up:

  1. Column Format: Button

Label: ="Update " + Feature

How the formula works: We are combining the word "Update" with the value in the Feature column

2. Action: Add Row. And, we're applying these changes to the Update Log table with the name of the Feature, the Update Date, and who created the new entry (Updated By). 

3. Open Row For Editing: In this case, we want this turned on so that the logged in person can add their notes.

Example 4 - Upvotes and downvotes

This example also takes advantage of the button column format. You''ll have three columns set to the button format - up, down, and clear:

To set up the voting structure, take the following steps:

  1. Create one table for your voting, and another table to track the votes. Keep in mind, these can be in totally different sections.

  2. Label: The up and down buttons will have a very similar set up:

Here, we're displaying the up or down emoji, and using a formula to show the current count of votes. If you want to keep vote counts secret, you can simply include the emoji. 

3. Action:  Both of these will also Add a row to the Votes table. Our set up completes the emoji, the question text from the vote submission table, and the voter's name using our favorite formula - User().

4. Disable If:  Since we don't want our voters to vote multiple times, we've set the button to disable if our vote tally table already has an entry by the user using the following formula:

Now let's take a look at the Clear button:

  1. Label: Here we'll simply use the text "Clear"

  2. Action: Delete rows. In this case, our target is the Votes tally table, and we're using thisRow and User() to connect a user's vote to the question.

3. Disable If: We also want to disable clear if the user has not voted yet. So, we'll use this formula:

Example 5 - RSVPs

The RSVP buttons combine the elements you've already seen with a text response using the SwitchIF formula:

For the Yes and No buttons, you'll take the following steps:

  1. Label - "Yes" or "No"

  2. Action - Add Row with the target being your Attendees table. 

3. Disable If: Here, we want to make sure people don't push the button multiple times so we can get an accurate count. So, we disable the button if we already have an entry from the user:

For the +1? button, you'll set it up to update the checkbox as true:

The final element of this button set up is the response that user's get in the text field once they add their response. To accomplish this, type = in the canvas and use the following formula:

Example 6 - Remove dupes button

If you're working with a large amount of data entries, getting rid of duplicate entries can be a very handy trick:

To set up the de-dupe button, take the following steps:

  1. Name: "Dupe Remover"

  2. Label: ="Remove " + [All Bugs 🐛].Filter([Dupe?]=true).Count() + " Dupe(s)"

How this formula works: We're grabbing the number of entries that are marked as duplicates using the Filter formula

3. Action: Delete rows with our target table being the All Bugs 🐛 table

4. Disable If: We don't need our button to be active if there are no dupes so we disable the button if the dupe count is 0. Here's the formula for reference:

Example 7 - Timers

This button set up connects a button to a dropdown select list control:

To set up the timer, you'll begin by creating a dropdown select list control and naming it "duration':

Now that you have the dropdown menu, you can create the button with the following settings:

  1. Name: "Timer Button"

  2. Label: "Click to begin"

  3. Action: Modify rows with the target being the Time table. We only have one row that we're modifying here. The value we update combines the Now( ) formula with the value in the "duration" select list in terms of minutes:

4. For the text letting you know how much time you have left, you'll use the If() formula:

Example 8 - Assigning tasks

Our last example lets you create a workflow around tasks that need to follow a particular process:

To create your workflow, first identify the steps and owners in a status progression table:

Then in your Handoff column format, you can use this data to drive direction:

  1. Label: ="Handoff to " + [Status Progression].Filter(Rank = thisRow.[Current Status].Rank + 1).Status

How this formula works: We use the Rank of the steps to change the button based on which step comes next in the process.

2. Action: Modify rows in the Content Production table. Again, we use the Rank option to connect steps to people:

3. Disable If: We then turn the button off if we've made it to the final step:

Did this answer your question?