Define how often a workflow should run

I use a Form where the user can define the amount how often a PDF should be printed.
After saving the form, a workflow rule is fired and the PDF ist sent to the Printer’s Email Address.
So if the user set’s the [Amount] to 5, the Workflow should send the PDF 5 times to the printer’s EMail Address.
How could I do that?

I tried several possibilities:

Decrement Count via Workflow
In the Workflow I set a second action after sending the Email: An Action that simply does: [Amount]-1
The idea is: After sending the Email, the Workflow will be triggered again, because the row changed.
Result: Email is sent, [Amount]-1 is done, but no other Email is sent.

Decrement Count via Action
I tried @Steve’s idea Add any number of rows from any row within a table. So by saving the form, an Action is doing [Amount]-1 until [Amount]=1.
The idea is: The Workflow would fire each time the [Amount] changes. So if the user would define [Amount] = 5, then it would fire five times.
Result: The Workflow fires only 2 times: One time when the row is saved and on time when [Amount] = 1. It seems as the changes of [Amount] are happening so fast, that AppSheet doesn’t recognize them.
So instead of going down from 5 - 4 - 3 - 2 - 1, it’s going down from 5 - 1. This is what I can see also in the Spreadsheet.

Using To, CC and BCC
This is the only working solution right now. I set them like this:
To: Printer_Email_Address
CC: IFS([Amount]>1,Printer_Email_Address)
BCC: IFS([Amount]>2,Printer_Email_Address)
Result: This is working, but I can sent the same Workflow only max 3 times.
If I use expressions in “To” like
IFS([Amount]>1,Printer_Email_Address)
IFS([Amount]>2,Printer_Email_Address)
IFS([Amount]>3,Printer_Email_Address)
They will be ignored.

Maybe someone has a Tip for me?

Hi @Fabian,

Request you to explore if following if it helps in any way. I tried to create a test scenario but I believe I will need a deployed app to test CC and BCC emails in workflow. So the following is untested.

Its it possible that you could create action 2 in the same workflow with reaction defined as 'Email" and TO:, CC: and BCC: defined with expressions you mentioned `IFS([Amount]>4 ,Printer_Email_Address)

If it is working, may be you could send emails upto 6 times. Of course , even if working,there could be some possibly limits on how many workflows can be fired in succession from same app?

Thank you @Suvrutt_Gurjar, yes I think this would work. This would be a Workaround.
But I would like to install a system to “print” as many times as desired.

1 Like

Hi @Fabian,

I got it. Just in case helps , you may wish to try the following approach based on reference actions between a parent and a child table. Technically this approach can be used for firing any number of reports that one desires.

All the children records (Column name [Counter] in each child record) are set to the identical count from parent column [TargetCount] through reference actions in parent record called +1 all. The maximum that [TargetCount] can be set is equal to number of children records ( 10 in the test app)

Now there is only one workflow rule set on child table to send PDFs as many times as the set [TargetCount] in parent table. The workflow has following condition

AND( [_THISROW_BEFORE].[Counter] <> [_THISROW_AFTER].[Counter], ISNOTBLANK([_THISROW_AFTER].[Counter]), [Counter]>=([_ROWNUMBER]-1 ))

The above expression ensures that the workflow is fired for only those children records where the ( rownumber-1) matches the [Counter] set in child record through reference action. Since child table is only used for firing reports, it is a static table , so row number is used for comparing reports count.

The parent and child table are simple two and three column tables
Parent:
image

Child table

image

If one wants the limit of reports number to increase to 20 , the number of children records and parent column [Targetount] max value need to be 20.

I tested with of course a tiny report based on parent record but fired from above mentioned workflow in children records with maximum of 10 reports fired in the test app.

Edit: Minor edits to description above.

3 Likes

@Suvrutt_Gurjar Thank you very much. This seems to be a solution. But I will need to read it many times to understand. Still learning… :slight_smile:

1 Like

Hi @Fabian,

Thank you. If you say you are learning, then I must say I can neither read nor write :slight_smile:

I have copied the test app to my portfolio. You may wish to copy the test app called “Workflow Reference Actions” at Copy App From Here

I had modified a sample app called 'Reference Actions" to do the needful.

3 Likes

Thank you so much @Suvrutt_Gurjar this is very helpful.

3 Likes