Automations
All questions related to Workflow Automation, AutomationEngine, and EdgeConnect, as well as integrations with various tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Delay send email action based on a variable input

intact658
Observer

Hello,

I've a workflow with two actions. First is a JS action that returns an output like this one:

delay_seconds = 300
recipients = [
 {
  "to": [email protected]
 },
 {
  "to": [email protected]
 }
]

Second is an email action. It uses result("js_action")["delay_seconds"] in "wait before" option. And it uses result("js_action")["recipients"] in "loop task" option.

This works as expected. Both users receive email after a delay of 300 seconds.

 

Now I need to modify the workflow so that js_action returns an output like this one instead:

recipients = [
 {
  "delay_seconds": 300
  "to": [email protected]
 },
 {
  "delay_seconds": 500
  "to": [email protected]
 }
]

But with this change I'm not able to use _.item["delay_seconds"] in "wait before" option.

How can I achieve this use case? User one should receive email with delay of 300s while user two should receive email with 500s delay.

This is simplification of the real use case. I want to avoid creating 100s of workflows (1 per user or team). Instead I want user to define their preferences in ownership object and use workflow to notify them as per their preferences.

Thanks,

 

2 REPLIES 2

sujit_k_singh
Champion

Hi @intact658 

The "Wait before" option is evaluated once for the entire task, not per loop iteration so _.item["delay_seconds"] won't work there.

You can go with Group by delay + Run Workflow action, I mean JS action groups recipients by delay_seconds, then loop through groups using Run Workflow action to trigger a child workflow per delay group. The child workflow has the email action with "wait before" set from the input parameter.

Thanks,

Sujit

Dynatrace Professional Certified

sonja
Dynatrace Champion
Dynatrace Champion

Hello @intact658 !

I'm curious about the real use case - could you share more details? that might help us suggest additional options.

thanks!
Sonja

Featured Posts