Trigger Workflow With A Simple Action Button

*This tip will let you trigger a workflow without having to double back and clear the trigger column.

Let’s create an action to trigger a workflow that sends an email.

  1. First, every table I create has a hidden trigger column, type text.
  2. Second, let’s create a simple data change action for the table that we want to trigger on with the following expression: CONCATENATE("UNIQUE_KEY_WORDS", " - ", NOW())
  3. The key word can be anything you want, but you’ll want it to be unique and descriptive to what you’re trying to accomplish. So if I’m sending a project summary email, I might make it PROJECT_SUMMARY_EMAIL
  4. Third, in our workflow condition expression use the following:
    AND(
    [_THISROW_BEFORE].[trigger]<>[_THISROW_AFTER].[trigger],
    STARTSWITH([trigger], “UNIQUE_KEY_WORDS”)
    )

This ensures that we can use our trigger column for many different types of triggers, and that we can also trigger the same workflow over and over without needing to double back and clear the trigger.

18 19 2,167
19 REPLIES 19

While I prefer to clear the trigger column, this way there’s no ambiguity around when a workflow should be triggered or not, this method provides a sort of history for what the last trigger was; nice one!

I generally prefer any method that has less moving parts/data changes.

Clearing the trigger method would be three actions, and two table record updates.

We often carry SQL change/history tables, so the second update to clear the record creates a “non-user” created second record update in the change table, useless… I should experiment with marking the trigger column to “reset on edit,” but it’s not really necessary. (Try to get the trigger history record to only show up for the person that used it, so I could get a history of workflow triggers)

Just two actions, and one update:

  • Set the value
  • clear the value

Since we can do multiple steps inside workflows, the first step I do is to clear the trigger inside the workflow - this means the only edit made to the row that we see in the app is the push of the trigger - everything else happens with the workflow.


I’m with you 100% about less moving parts.

Nice use of StartsWith() BTW 3X_d_5_d51363a862e7ab883241c312ac5d7f271579cdd3.gif

Ahhh, yes, yes.
It’s still two database updates.

Hi @Grant_Stead and @MultiTech_Visions !
Both of you have far more experience than me on AppSheet (I made my first “contact” to AppSheet at the end of 2019 and started full on January 2021)
I made something similar but with a number column that gets +1 with my action button and the bot has this condition:

[_THISROW_BEFORE].[UPDATE_COLUMN]<>[_THISROW_AFTER].[UPDATE_COLUMN]

I also tried with > instead of <>
The problem is that I have two of the same setups and one of them always triggers the bot after I change any other column from that row.

  1. There is something else related to the way [_THISROW_BEFORE] and _AFTER works?
    I mean, if I change any other column, the UPDATE_COLUMN should stay the same before and after, right?
  2. Is your setup better in any way that would help me overcome my problem or it’s just another way of doing the same thing?
  3. I was thinking that I would make the UPDATE_COLUMN datetime type and then add 1 minute or something to it with the action button and then place [UPDATE_COLUMN]>NOW() as condition so I would bypass the _THISROW_BEFORE and AFTER stuff completely. Do you think that would work?

Thanks in advance!

However, we’d need to dig deep into your stuff to figure out why exactly it’s getting triggered when you don’t want it to. Drop a loom…

Instead of trying to do all of this clever stuff, I stick to a crazy simple scheme.

Create a column that’s hidden in all respects, that’s a text type, in which you can put specific triggers. I’m talking about creating a specific action that sets a specific value to this column, then you base your automation triggers off of the fact of this column having that specific value.

As long as you remember to clear the trigger value before finishing the automation, this system has never led me wrong. There’s no confusion to be had about when something should fire or not.

I’ve created systems where I’ve tried something like what you’re doing, where I will try and come up with some formula that can detect the change that would trigger the automation.

  • but the fact of the matter is, most of the times whenever a automation is being triggered it usually corresponds to some data change being made by a person. So in my mind I can just use that data change the person made and incorporate the trigger there.

Are you forgetting to check if it is not blank as well? A blank value will result in a BEFORE <> AFTER being TRUE. Or at least it did in the past maybe the recent-ish change for comparisons against blank values fixed that?

For the record, I do almost exactly what Grant described in the original post here. Although I never saw this thread before, and this is probably only the 2nd time I ever even heard of the STARTSWITH() expression, brilliant! In fact this template condition expression is even saved in my clipboard manager for super easy access.

AND(
  ISNOTBLANK( [trigger] ),
  [_THISROW_BEFORE].[trigger] <> [_THISROW_AFTER].[trigger] ,
  INDEX( SPLIT( [trigger] , " ; " ) , 2 ) = "xxx"
)

Intended to trigger on a data-change Action like:

UTCNOW() & " ; " & "xxx"

There it is! I tested both of my tables that has the setup I described above and both of them trigger the event when the column is blank.
I guess I’m gonna make them default to 0 or change it to a more elegant solution as @MultiTech_Visions and @Grant_Stead are doing.

Thanks again @Marc_Dillon. I told you that you were a very helpfull person!

Yes, the method I outlined is far superior…

That’s exactly why I put a keyphrase in the beginning. So that you can use one trigger column but have many different triggerable events.

Thank you very much to both of you for your time.
@Grant_Stead For sure that’s superior, with my actual setup I would need one column for each of the actions/bots. I don’t need that flexibility for the moment, but I’m a litle bit tempted to use your trick in the future.

@MultiTech_Visions I also like to make things simple sometimes. I can see how the two-steps thing would help since after the action/bot is trigger the column would be blank again and then the bot shouldn’t be triggerer again by accident. Am i right?
Also, just the fact that there are two changes to the column (the first one with the trigger value and then the one that clears the thing) is enough for AppSheet to notice that there was the trigger value and do it’s thing (bot-side)?

Also, have you encountered a moment where you would prefer to make an adds only event instead of a update one just for reliability reasons? I’m asking that because Adds Only works perfect every single time but personaly I have struggled with Updates Only ones to the point that I’m thinking on not use them anymore. Should I just keep debugging and not give up with Updates Only events?
Thanks again!

All the time

  • Being able to trigger on an Adds_Only really helps eliminate any “cross-contamination” - same things for updates; I can put automations with an update trigger and know for sure that it won’t execute when a record is made.

Hi,

Have used the above method to trigger emails but I have the problem that my users often update the row in which the trigger column is located after they have hit the action button that sets the trigger column.

I have this as the action

CONCATENATE(“Products”, " - ", NOW())

and this as the condition

AND(
[_THISROW_BEFORE].[Send Stock Email]<>[_THISROW_AFTER].[Send Stock Email],
STARTSWITH([Send Stock Email], “Products”)
)

It works great as a column that can trigger different emails but there is no option to only trigger on an update in a certain column only.

Even if I set the trigger column to " " after the email is sent, the condition is met long enough for the user to make edits and trigger more emails.

Thanks

phil

You could take to forcing a sync after an automation is triggered

  • I do this quite often when I have something that I need to ensure “happens”

So as soon as a user hits the action, the app begins a sync process - thus preventing them from doing anything else, and also speeding up the execution of your automation (as it’s being forced to run NOW).

The app has about 24K rows and 40 tables and takes about 1 miute to sync so would slow down all the users too much. I can’t break up the app anymore to redcuce the sync time.

thanks

Phil

How is this a problem?

Not sure what you mean here. There absolutely is such an option, and you’re already using it; your bot is only triggering on changes in the [send stock email] column.

Not sure what you’re saying again. Are you saying that more emails are being sent out than what you’re wanting?



I assume this is the same issue as in your other thread:

Please describe in more step-by-step detail exactly what is occurring.

Let’s move this to it’s own thing…

OH mate I got you! @Phil_Waite

omg I don’t know why I didn’t think about this sooner.

Create a composite action for the visible button, with two actions inside:

  1. Set automation trigger
  2. Clear trigger

Because they both happen immediately, there’s no time for the user to “get in the middle”

  • This should prevent the user from…

Because the trigger is immediately removed, you shouldn’t have any problems.

Hi,

I think the problem was because I added the clear trigger column as the last step in the bot rather than as part of a sequence of actions.

Problem solved.

Thank you

Top Labels in this Space