A workflow with dynamic Waiting time

mahmoudhabiball
Giga Contributor

Hi,

I have the following Problem:

I have a catalog Item, that can be requested via Form. Once Requested, a workflow will be triggered on this Item.

The Item includes data to activate an AD User. But the activation time depends on the input. If the input says, the user should be activated in one month, then the workflow needs to wait there for one month.

And because the workflow might be running and waiting for a long time, I want to be able to cancel it (changing the state of the request).

Is that possible? And what is the best way to implement this in ServiceNow?

Thanks

1 ACCEPTED SOLUTION

Yes if you choose "Timer based on script" then you can calculate the amount of seconds it should wait - pr RITM depending on your input.

If the input says, the user should be activated in one month, then the workflow needs to wait there for one month.

View solution in original post

6 REPLIES 6

Simon Christens
Kilo Sage

Hi

In a wait condition activity you can put an answer to the amount of seconds the wait timer have to wait before continue.

So depending on your input you can convert it to seconds and parse it into the wait condition through workflow.scratchpad

I dont know if your input is a date/date time (if so gs.dateDiff() can be used to calculate the amount)

https://docs.servicenow.com/bundle/jakarta-application-development/page/app-store/dev_portal/API_reference/GlideSystem/concept/c_GlideSystemAPI.html#ariaid-title17

If its x days you can calculate it with x days * 24 * 60 * 60

So you mean, I defined a timer, that waits as long as it needs. On the right moment, the result will be set to true. Setting the value to true, would let it then continue?

Yes if you choose "Timer based on script" then you can calculate the amount of seconds it should wait - pr RITM depending on your input.

If the input says, the user should be activated in one month, then the workflow needs to wait there for one month.

I see. Timer based on a script is the better way  to go