Skip to main content

Conditional actions (if and else)

Run actions only when a record meets your conditions. Add an else branch for everything else, and nest conditions to handle several cases in one automation.

Written by Leo

Conditional actions is an action that runs the actions inside it only when your conditions are met (the conditions decide whether the block runs, and the actions inside decide what happens). It's meant to help you handle different cases in a single automation, instead of building several automations that each start the same way.

You can use this action for many things, including:

  • Adding a comment for the finance team only when an expense is over the spending limit.

  • Assigning a task to a different teammate depending on the lead's region.

Adding Conditional actions in an Expenses automation: Add action, selecting Conditional actions, then Add filter with the condition Amount > 5000 and Add action inside the block

Note:

  • A trigger filter and conditional actions do different jobs. The filter decides whether the run starts at all. Conditional actions decide what happens inside a run that already started.

  • Actions below the block run in every case. Only the actions inside the block depend on the conditions. To stop everything for some records, use End run inside the block.

  • Nesting has a maximum depth. Blocks inside blocks work, but only up to a maximum depth. For deeper logic, move steps into another automation with Call automation.

Who can use the Conditional actions action?

  • Automations are available on all plans: Free, Plus, and Premium. The number of automation actions per month depends on your plan. See the limits for your plan on our pricing page.

  • To add or change this action, you need to be a workspace admin of the workspace the database app is in. You also need full access to every database the automation uses.

Add the Conditional actions action

To run actions only when conditions are met:

  1. Open the database app and click the automations icon in the top bar (tooltip Create and view automations). The icon is only there for workspace admins, and not on mobile.

  2. Open an automation, or select New automation and choose a trigger.

  3. Select Add action → Conditional actions. In the list, it reads Run actions only if the conditions are met.

  4. Select Add filter and set the condition.

  5. Select Add action inside the block and add the actions that should run when the conditions are met.

  6. Select Create automation for a new automation, or Save changes for an existing one.

The Conditional actions block with the condition Amount > 5000, five actions inside it, and the else branch Else if conditions are not met

Conditional actions settings

The block has two parts. Its first line reads If the following conditions are met. Below it, the actions that run in that case are listed under Actions.

  • Add filter: adds one condition. Open the dropdown, select a field, then select how to compare it, for example Contains, and enter a Value. The first condition reads Where.

  • Add filter group: adds a group of conditions. Use a group when you need to mix conditions, for example one condition and either of two others.

  • And or Or: filters and groups are joined with And by default, so all filters must match. Select And in the second row and choose Or if at least one filter must match. The choice applies to all filters and groups at that level.

  • Add action: adds an action that runs when the conditions are met. You can add any action, including another Conditional actions block.

  • Else statement: adds a second branch that runs when the conditions are not met. Open the block's menu ••• and select Else statement. The branch is labeled Else if conditions are not met.

The conditions work like the filters on a trigger. You can compare field values and values of the trigger. To check a value from an earlier action, such as Perform calculation, use a script filter. Learn more about filters →

The block's menu ••• also has Settings, Continue on error, Deactivate, Turn into, Duplicate, and Remove. Learn more about action settings →

Name the block

Select the title Conditional actions and enter a name that says what the block checks, for example Over the limit?. You can rename the condition line If the following conditions are met and the else branch Else if conditions are not met the same way. Names help when you read a run's steps later.

Let's look at an example

Let's say your finance team wants every expense over $5,000 to get a comment, and smaller expenses to be approved right away. Here's how:

  1. Set the trigger to When a record is updated and select the field that starts the approval, for example Approval.

  2. Select Add action → Conditional actions.

  3. Select Add filter and set the condition Amount > 5000.

  4. Select Add action inside the block and choose Add comment. Write "Over the $5,000 limit, please review and approve", and mention the approver.

  5. Open the block's menu ••• and select Else statement.

  6. In the else branch, select Add action → Update record and set Status to Approved.

  7. Select Create automation.

The next time an expense is submitted, you should see only one of the two branches in the run's steps. Expenses over the limit get the comment, and all others are approved.

Scrolling through a Conditional actions block with its condition, the actions for amounts over the limit, and the else branch

Handle several cases

To handle more than two cases, put another Conditional actions block into the Else statement branch. Each block checks one more condition, so you can build a chain such as "over $5,000, over $1,000, everything else". You don't need a separate automation for each case.

To end the run for some records, add End run inside the block. Learn more about End run →

Check more than fields

When a condition on a field isn't enough, calculate the check first. Add Perform calculation and write an expression that returns a value. A classic filter can't select this variable. Open the filter's menu •••, select Turn into script filter, and use the variable in the script.

For example, lead_field_email_email.endsWith('@acme.com') tells you whether a lead uses a company address. The editor suggests the exact variable names as you type. Learn more about Perform calculation →

Conditional actions errors

  • A block with no condition runs every time. If you add a block and don't set a condition, all actions inside run for every record.

  • If a condition doesn't match as you expect, check the values it compares. Learn more about filters that don't match →

  • If a run didn't do what you expected, open the run and check which branch ran. The steps show each branch that ran, with its status.

  • If you can't drop a block inside another one, you've reached the maximum nesting depth. Use Call automation to move part of the steps into another automation. Learn more about Call automation →

Test, pause, or edit the Conditional actions action

  • Manual run runs the automation once. Under Run on, select the records, then select Start run, or Save and start run if you have unsaved changes. Filters apply, so only matching records lead to runs.

  • A simulated run skips the trigger filter and doesn't change data, so you can see which branch a record takes. To test the trigger filter too, use Manual run. Learn more about testing automations →

  • To skip the block without removing it, select Deactivate in its menu. A deactivated block is skipped completely, including all actions inside it.

  • To change the conditions, open the automation, change the block, then select Save changes.

Learn more

FAQs

Can I add an else branch?

Yes! Open the block's menu ••• and select Else statement. The branch runs when the conditions aren't met.

Can I put a conditional block inside another one?

Yes. Add Conditional actions inside a block or inside its Else statement. There's a maximum nesting depth, so move deep logic into another automation with Call automation.

Can I check the text of a comment?

Yes. Use the trigger When a comment is added, add Conditional actions, and compare the comment text with Contains. Select Add filter and choose the comment's Body, then Contains.

Can I write the condition in JavaScript?

Yes, for conditions that need more than a field comparison. Open the filter's menu ••• and select Turn into script filter. Write a JavaScript expression that returns true or false, and type @ to insert values. To switch back, select Turn into classic filter. You can also calculate the result first with Perform calculation.

Do actions after the block still run?

Yes. Only the actions inside the block depend on the conditions. Actions below the block run for every record. To stop the run, add End run inside the block.

Are you a developer using the Tape API for automations?

The automation API has its own documentation for developers. Full reference: conditional in the developer docs →

Still have questions? Find answers and get help from community experts in the Tape community →

Did this answer your question?