Workflow Wait Condirion

John H1
Tera Guru

I have a need to create a Wait Condition in a workflow that would trigger an Activity on a date. Business case, we have a user out of the country and will be returning on the 15th of July. On the 15th of July a returning activity would be generated.

 

1 ACCEPTED SOLUTION

John H1
Tera Guru

I was able to resolve this issue using a Timer with the following script
// Set 'answer' to the number of seconds this timer should wait
answer = gs.dateDiff(gs.nowDateTime(), current.variables.scheduled_return_date, true);

View solution in original post

4 REPLIES 4

SwarnadeepNandy
Mega Sage

Hello @John H1,

 

You can use the wait for condition activity to create a workflow that would trigger an activity on a date. For example, you can create a workflow that would generate a returning activity for a user who is out of the country and will be returning on the 15th of July. To do this, you can follow these steps:

  1. Navigate to Workflow > Workflow Editor.
  2. Click New to create a new workflow.
  3. Enter a name and description for the workflow.
  4. Select the table that the workflow applies to, such as User.
  5. Click Submit to save the workflow.
  6. Drag and drop the Wait for Condition activity from the palette to the canvas.
  7. Double-click on the activity to open its properties.
  8. In the Condition field, enter the condition that you want to wait for, such as [sys_updated_on] [on] [2023-07-15]. This means that the workflow will wait until the user record is updated on the 15th of July.
  9. Click Submit to save the activity.
  10. Drag and drop another activity from the palette to the canvas, such as Notification or Script.
  11. Double-click on the activity to open its properties.
  12. Configure the properties of the activity according to your needs, such as selecting a notification template or writing a script that generates a returning activity for the user.
  13. Click Submit to save the activity.
  14. Connect the wait for condition activity to the next activity with an arrow.
  15. Save and publish the workflow.

You can also use other methods to trigger an activity on a date, such as using a timer activity or a scheduled job. However, using a wait for condition activity may be simpler and more flexible for your use case.

 

I hope this helps.

 

Kind Regards,

Swarnadeep Nandy

This is very close to what I was thinking, We have a variable "Scheduled Return Date" that is the "Condition: variable. How can I get ServiceNow to trigger on that date?

The return date would be a variable "Scheduled Return Date". How can I use that in the solution?

John H1
Tera Guru

I was able to resolve this issue using a Timer with the following script
// Set 'answer' to the number of seconds this timer should wait
answer = gs.dateDiff(gs.nowDateTime(), current.variables.scheduled_return_date, true);