cancel
Showing results for 
Search instead for 
Did you mean: 

Script to create a pause of 5 seconds in workflow

GILBERTO_CORUJO
Champ on-the-rise
Champ on-the-rise

Hello:

Do you have a script to create a pause of 5 seconds in a workflow?

I appreciate your help.

1 ACCEPTED ANSWER

dave_sanderson
Star Contributor
Star Contributor

Hi Gilberto,

I am just curious why this must be a script? There may be some reasons NOT to do it this way, but you can use recursive native workflow to delay for five (or more) seconds. This is wont be exactly five seconds, but depending upon how important pausing for exactly five seconds is and you have a bit of wiggle room - as in 5.1-6 seconds wont mess up the processes - this seems to work for me in version 15. not sure when the expression function ceil became available though so your results may vary:

  • using the action Set Property to Expression create propWaitUntil property and set it equal to ceil(now()*24*60*60)+5. This sets the current date time in seconds (24 hours a day, 60 minutes an hour, 60 seconds per minute) to five seconds in the future. 

  • using the action Set Property to Expression create propNow property and set it equal to ceil(now()*24*60*60). This captures the current date time in seconds.

  • using the rule Compare Property Value set PropWaitUntil is < propNow indicating that the time I had set to wait for in the future (that is + 5 seconds) is less than the time (in seconds) now, so the wait has been completed

  

    • Under True branch (wait is over)
      • I added a message box stating that five seconds are up

      • BREAK - I added a break after the message box, but you would not want it because it prevents what ever comes after the Task List from being evaluated. I would avoid putting steps unrelated to waiting five seconds in this task list. That way you could just copy/paste this Task List next time you want a five second rest and not worry that you have other actions/rules that are NOT strictly involved with waiting five seconds
    • In the false branch
      • drag and drop or copy/paste the same action that created propNow
      • Copy and paste the Rule created above into the False branch

the whole thing looks like this - note that you can keep expanding false branch of the rule forever and will keep getting the repeat. versions ago if you shift + right arrow, the configuration client (where workflow used to be configured) would crash as the branches kept expanding. that does not happens in Studio (*phew*). I only expanded three false branches, but you get the idea

so I am very interested in hearing why i should not do this 😉 I get it may take up more processing power than a script, but how much more and how big of an issue is that?

thanks all - I am looking forward to the comments !

View answer in original post

8 REPLIES 8

This is great!!
Thanks so much Dave.

This is great!!
Thanks so much Dave.

This is great!!
Thanks so much Dave.

Hi Alex,

Thanks for your comments! I was exposed to recursive workflow back in OnBase 8 (maybe 9??) and use it occasionally, especially to prevent blank entries in an ad hoc task/user form or rarely evaluating user input. Right now what I built is just in the Dev environment not actively being used. Minimal proof of concept type testing showed it worked, though not enough to gather sufficient information to do more. It was built because I saw Gilberto's question and I thought this could be done without scripting - though certainly because it CAN does NOT mean it should be done!

I have not put in a counter as Jeremy suggested, but when I get back to it I will - unless Gilberto beats me to it - though for me it will not be in the next few days. Doing some work is interesting thought too, though similar to you, relying on that work to be consistent and reliable to that level of precision makes me---itchy 😛

Thanks for your comments and thoughts - i do enjoy learning from you!