Recalculate Workflow Timer When Value Changes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2014 04:06 PM
I'm using a wf Timer activity to pause until the 'Disable Date" on a Request Item is reached. The next step in the wf runs a "Disable AD User Account" Orchestration activity.
Issue: I need the wf Timer to reset if the Disable Date data/time is change on the Request Item. This is required in cases when the termination date or time changes from when it was originally scheduled...or when it is submitted incorrectly. Is there a way to reset the timer if/when the "Disable Date" field changes?
- Labels:
-
Orchestration (ITOM)
-
Service Mapping
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2014 05:07 PM
My first suggestion would be to attempt using the Workflow Script function restartWorkflow while setting the second parameter to true (maintainStateFlag). With all of your Approvals and Tasks in the same state, the workflow should restart, zip right past all of the approval and task activities and wind up back at your timer.
Workflow Script - ServiceNow Enterprise Wiki
Realizing that a sufficiently complex workflow could negate this possibility, you could possibly add a rollback activity after your timer with a condition that if the timer was cancelled, the workflow will rollback before the timer (effectively restarting it). Then you could have a business rule that cancels the timer activity when the date field changes.
Finally, you can take a look at the Activity definition for some info on how you might be able to manipulate it externally:
- Activity Scratchpad Variables
- sys_trigger job named 'WFTimer' + activity.sys_id
- onPause, onResume functions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2014 07:13 PM
Travis has the right idea on the sys_trigger job list. Every "timer" workflow activity creates a record in the sys_trigger table with the name 'WFTimer' + the sys_id of the instantiated workflow activity.
You could create a business rule on your sc_req_item table with the conditions for that workflow that specify "if this value changes and it's for this particular request, made a modification to the sys_trigger table."
Your flow would look like this:
User changes disable time
Business Rule fires
Business Rule looks up your current context record
Business Rule finds the timer actively running in the current context record
Business Rule finds the sys_trigger named 'WFTimer' + the sys_id of the timer activity actively running in the current context record
Business Rule changes the next action time to be whatever is in the Request Item.
What might be easier and more scalable is a loop in your workflow, provided you never decrease your disable time. It would be something like this:
Run Script activity sets a workflow scratchpad variable equal to your wait time duration
The timer activity can accept a script, so you would set the answer to be equal to your scratchpad variable
The timer runs out and then passes through an if script: "Is the time in the request item less than the current time?"
If it's less, that means we're good to disable. If it's still greater than the current time, the if script sets the scratchpad variable to the new duration and loops back onto the wait condition.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-17-2014 07:49 PM
Thanks for the suggestions. I will give them a try and let you know how it goes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-26-2014 06:27 AM
Hi,
I have similar requirement. Please let me know how you achieve the same.