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
0 12 640
12 REPLIES 12

Steve
Participant V

@Phil, do you have any suggestions?

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

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

MultiTech
Participant V

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.

@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โ€ฆ

Weโ€™ve all been there! 3X_d_5_d51363a862e7ab883241c312ac5d7f271579cdd3.gif

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).

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=Fal...

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โ€)

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.

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.

MultiTech
Participant V

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. ) 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.

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

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!!

Top Labels in this Space