How to fix error exception when call subflow which is setting "wait for a duration flow logic" ?

HuyVu
Tera Contributor

Phenomenon:
I added "Wait for a duration flow logic" and set "wait for 3 second(s)" before the "Update Alert Record" action in my Subflow, as shown in the image below.

find_real_file.png

Then, on the Scheduled Job side, when the above Subflow was called synchronously, an exception was generated.

find_real_file.png

The content of the exception is "com.glide.plan.runners.FlowObjectAPIException: The current execution is in the waiting state".

Why do exceptions occur? How to solve it? Could you please tell me?

Postscript:
When I call the above Subflow asynchronously, no exception is raised. I'd like to know why it doesn't happen, but I don't want to do the asynchronous method.

4 REPLIES 4

surajp
Mega Guru
I suggest you call it asynchronously since the subflow has wait for activity. If you call synchronously it make the scheduled job to wait till subflow finishes which causes the problem. If still you want to call syncnously wrap the subflow in another flow where you can call it synchronously.

HuyVu
Tera Contributor

Hi surajp,

Thank you for your reply.
I tried it the way you recommended.
I created another Subflow that wrapped the original Subflow.
Then, I tried to call a new Subflow on the ScheduledJob side, but still got an Exception. It seems that it cannot be solved yet.


If there is another method, please let me know.

Thanks!

Che Pazzo
ServiceNow Employee
ServiceNow Employee

Same here. My guess is that they are avoiding ever having something sit-and-spin.

I think the only way around it is to add a new script action to your flow that calls gs.eventQueue.

Then, write a ScriptAction as a callback.

see

https://developer.servicenow.com/dev.do#!/learn/learning-plans/paris/new_to_servicenow/app_store_lea...

for details on event queue

 

Jorge Almodovar
Tera Contributor

You can create a new Activity that acts as a timer but in fact is a gs.sleep. Add an input parameter that takes seconds. The add a Script step that takes that input and multiply them by 1000 and set it on your gs.sleep(inputs.seconds*1000). Add that activity to your flow/subflow and you won't get the error anymore.

find_real_file.png