Conditionally send an email from a workflow

For a single table X, I have a workflow that is triggered by column B changing values:

  • task 1: action: update value of column A
  • task 2: send email if A is set a certain way
    ie. sometimes the workflow should only do task 1 and sometimes it should do both task 1 and task 2

Since there is no condition on the email task I am struggling to find a solution to this that doesn’t involve duplicating workflows to handle each disjoint case.

Problems:

  • it is not possible to send a complete email from an action, only start an email is possible, so I can’t convert task 2 to call an action that sends an email
  • cannot use two back-to-back workflows because they can run in an unpredicatble order (related to my workflow ordering question)

The simplest/best I can come up with is to always send the email but use logic to create an empty To: list in the cases where I don’t want to send the email.

Another solution would be to have two workflows W1 and W2, each triggered with disjoiint logic to achieve the desired effect of selecting the workflow that will send the email.

Features that would solve this cleanly:

  • allow an action to completely send an email
  • add a condition on the email task within a workflow

@Phil, do you have any suggestions?

3 Likes

Whaaaaaaaa? Not sure what you mean by this.


The solution is right in front of you (you actually mention it twice)… separate out your workflows into two separate ones

  • one will trigger the other

There is no confusion about which of these workflows would fire of first.

In regards to your previous discussion about workflows and when they fire off:

  • Had you mentioned this in that discussion, answers there would have been different.
1 Like

@MultiTech_Visions not sure how to inline responses…

on the first point: if I look at the available action in the actions section (not in a workflow) there is only “Start an Email” but not the full send an email like is available as a workflow task. Note I am using “action” and “task” to distinguish between the two ways to “do something”.

I will try the triggering approach again, when I did it before the order in the log was unpredictable and it wasn’t working. I’ll retry, most likely I set something up wrong and that led to all my questions…

1 Like

We’ve all been there! partyparrot (Appsheet)

I couldn’t tell you how many times I’ve reached out to Support@AppSheet.com, only to have them be like “uhh… you forgot to do X” haha


But you should know that if you’re using the action to open an email

  • that won’t work in a workflow.

That type of action is used to launch a user into an email app; whereas the workflow email thing is for sending complete emails (generating a file, sending it off).

2 Likes

We do not currently make this easy.
The best option at this point is to define two workflow rules with the appropriate conditions.

5 Likes

I re-checked and stripped down my app in a sandbox area. I find that workflows are not being retriggered as I would expect.

Layout:

  • table_A is the parent and table_B is the child
  • workflow_1 sends an email when the table_B:_STATE changes
  • workflow_2 updates the table_A:_STATE when table_B:_STATE changes to a couple specific values
  • workflow_3 updates the table_B:_STATE when table_B:fieldA changes

Here is what is happening on the save of the form that initiates the use case of interest, and the audit log agrees (and related to my other post) (I can share a screenshot of the log if needed):

  • workflow_1 runs and its condition is false
  • workflow_2 runs and its condition is false
  • workflow_3 runs and its condition is true and it updates table_B:_STATE as expected
  • no more workflows get triggered

I would like to share my app’s definition but I am not sure if this works (I set it to have users in the entire domain):
https://www.appsheet.com/Template/AppDef?appName=RH-Participant-debug-wf-ap-1-2165388&quickStart=False#Data.Tables

To run the app: https://www.appsheet.com/start/2a4695e1-711b-4975-a5b6-b7a47d16adfc

To see the audit log (I hope): https://www.appsheet.com/manage/viewLog?appTemplateId=2a4695e1-711b-4975-a5b6-b7a47d16adfc

The two tables:
Participant Info: Participant Info - Google Sheets
Application Processing: Application Processing - Google Sheets

To reproduce in the App:

  • click the + button in the table view
  • type in a name and select one of the CM Org choices, just pick the first one
  • now the participant info row has been added as well as a new applicaiton processing row and we are in a form for editing that new row
  • to trigger this particular use case, select “Fail” in the “Referral Result” and Save
  • the application processing row _STATE will transition to Fail but the participant info row will not transition its _STATE as desired (to the value “Exit”)

will the new Automation improve some of these non-orthogonalities and ease of use cases?

  • actions vs. task email handling
  • trigger conditions per-action can look at BEFORE state
  • workflow ordering/triggering issues

Stephen,
I am not sure I am following, but are you aware that Data Change actions do not trigger workflows?

See topic " Workflow Rules are Not Triggered" in this article Workflow | AppSheet Help Center

Data Change made by the REST API do invoke workflow rules. The REST API can be invoked from a workflow rule using a webhook.

3 Likes

Then I am thoroughly confused about how to have one workflow trigger another one, @MultiTech_Visions maybe some clarification would be helpful, I am certain I am missing something key here if both you and Phil are both making statements that are true.

That confusion would be on my part, I misspoke when I said:

What I actually ment to say is, migrate your data change to an action - and have that trigger your workflow. (I know, nothing like what I said before. :frowning_face:) But that’s what I was thinking in my mind, and intending to convey - I just failed horribly at that one. Mia culpa

Instead of using a workflow to accomplish the data change, you can migrate those into composite actions and view event actions.

2 Likes

thanks a bunch for all your help! I am slowly wrapping my head around the cases… :slight_smile:
If I had read the Workflows doc closely and internalized it, I would have not asked so many questions…

2 Likes

There is a lot to learn with AppSheet - A LOT - and we’re all still learning, even myself. It seems like every day I discover some new thing that I can do with AppSheet.

Good luck!!

2 Likes