You are viewing limited content. For full access, please sign in.

Question

Question

Workflow delay X seconds

asked on November 12, 2019

Hello,

 

We have a workflow that checks a database value.  The default value is "0".  It needs to loop using a repeat until the value is "1".  The table is update by a 3rd party piece of warehouse automation software when it is completed processing of the item.  Once it sets the value to "1", Workflow would then continue on when it checks the next time.

 

We would like it to check the database every 10 seconds for an update.  I initially used the date token calculator and tried adding 10 seconds to %(datetime).  The resulting token was then set as the "delay until" value in the delay activity.  This seems to delay for 60 seconds regardless of the value I input.  I suspect the delay activity isn't able to do less than 60 seconds even in the "delay until" function.

I then used a vbscript with a threading.sleep(10000), however I read Miruna's comments on why it is not recommended to do that, and it makes sense.

 

So, what is the recommended method if I need to perform an action repeatedly in a workflow and loop until a specific value is found before proceeding if I don't want to wait 60 seconds between poll intervals?

 

Thanks,

Jason

1 0

Replies

replied on November 12, 2019

There isn't really a mechanism for delays in seconds and as you already know the workarounds using scripts are not going to be efficient or as precise as you might want/need.

Workflow utilizes Windows scheduling components, which I believe is the reason the minimum delay is 1 minute. If you notice, there's actually a quirk in those Windows components where a 1-minute delay often ends up taking slightly more than a minute because of something about it rounding up to the nearest full minute (again, a quirk with Windows not Laserfiche workflow).

When you get to the point of loops every 10 seconds, it sounds like you need some kind of web service that will take in the request and send a response when the work is complete. As an example, I have a web service that processes payments. Workflow uses the web request activity to call the API, and when the transaction is complete, the API sends a response; this can take anywhere between 5 seconds to a minute, but instead of looping to check results, the web request is a synchronous activity meaning it just waits for the response until either it is received or the timeout period elapses.

Basically, if you can't afford to wait a full minute (and I can understand that may be necessary at times) then it sounds you need synchronous rather than asynchronous processing. The only way to accomplish that is with web services that can receive information from workflow and send a response as soon as the task is complete.

1 0
replied on November 12, 2019

Hi Jason,

Thank you for the response.  We would really like to keep everything inside of Workflow if possible due to the number of moving parts to this overall project.  Interestingly, I had done some research on the delay activity in the Windows Workflow Foundation.  It seems like it allows for a delay definition of hh:mm:ss, so I wonder if the minimum of a 1 minute delay is perhaps a Laserfiche limitation for some reason?  Reference here: https://docs.microsoft.com/en-us/visualstudio/workflow-designer/delay-activity-designer?view=vs-2015

0 0
replied on November 12, 2019

From what I understand, it seems a limitation within Windows. A similar issue arose on the Windows Mobile operating system. Basically, no matter what time you sent to scheduler, it only checked on full minute intervals, and this prevented people from making accurate timers for Windows Mobile devices.

I believe this trait is shared with Windows in general, as a result even if you send it a time that is exactly 10 seconds from the current time, it doesn't actually check at that time. Instead, Windows checks once every minute to determine which tasks are at or past the point where they need to be run.

I could be wrong, but I know that workflow utilizes a lot of built-in Windows components, and last time I checked even the Windows Task Scheduler doesn't have an option of less than a minute. Again, this is mostly speculation based on some of the behavior I've seen in Windows and Workflow.

1 0
You are not allowed to follow up in this post.

Sign in to reply to this post.