Run an automation when a button is clicked

Hi, we want to run an automation when a button is clicked.

Automations are much more powerful than the interface of a button and it would be such a game changer for our company!

1 Like

Hi Raul,

Strictly speaking I don’t think that can be done, but you can achieve the same end result nonetheless.

(I’m not a Codan, let them correct me where I’m wrong here).

TL;DR: What you want is to create a button to run the same actions as the automation.

Both Automations and Buttons are things that run actions. Despite their interface being different, they’re equivalent. See this table for comparison:

Automation Button
Trigger When (periodically) Click or call from another Action
Conditional If Disable If
Actions Action Then [More Actions] or Formula Action or Formula

The first thing is the triggers. For the Automations you have a When clause that is checked periodically. On the other hand, Buttons can either be clicked by a user or pushed/called by another Action.

That’s why you can push a button from an automation rule, but not the other way around.

Another difference is that the conditional clauses on both are also inverted, so if on your Automation you have If [Formula], you need to set your button’s Disable If to Not([Formula]).

Finally, an Automation you can execute multiple actions by adding Then blocks. That method is not there for a button, but you can do the same with a formula. See RunActions.

Hands-on

So going back to your scenario. It seems to me that you want to get rid of the When rule, and instead trigger some actions by a click.

According to the table above then you need to get rid of the automation and just use a button instead.

Say your Automation rule looks like this:

When [trigger]
If [condition]
Then [action 1]
And Then [action 2]
...
And Then [action n]

If you click on the f on each Then block you’ll see the formula for each action.

Then [Formula 1]
And Then [Formula 2]
...
And Then [Formula n]

Now you create a button, and its action should be a RunAction formula containing all formulas copied from above:

RunActions([Formula 1], [Formula 2], ... [Formula N])

Maybe a pic can explain it better:


Just a final word for the Codans, maybe adding Then blocks to buttons would be a good idea.

3 Likes

Hey @Dalmo_Mendonca, thank you for the thorough response.

This could work if I could get the Result from Step 1 in the RunActions formula. Unfortunately, I can not get those results (that I know of).

Do you know a workaround to get the results from each of the actions in the RunActions formula?

If simply re-querying the rows in the consequent actions doesn’t work for you, the workaround would be to create a small aux table and store the result in a cell. E.g., AddRow() returns the row — you can wrap it and put it in the aux table like @AuxTableRow.ModifyRows([Step 1 result], AddRow(...))

2 Likes

Step 1 Result is just the row that triggers the automation. In the case you’re manually pushing the button that doesn’t really make sense, so you need to reference the values you want (for example, using thisRow).

For the intermediate steps, what Paul said.

1 Like