How to get outputs when we run flow action asynchronously.

Harshit Sharma1
ServiceNow Employee
ServiceNow Employee

Say we are calling a flow action async. We make 5 such calls. Now for each call that is happening in parallel, how can I get its output? Is there a way to write callback handler?

5 REPLIES 5

Sandeep Rajput
Tera Patron
Tera Patron

@Harshit Sharma1 You can use a combination of Script Action and an event to process the output of flow actions asynchronously. Just trigger the event when you receive the response from a flow action and provide your output as param1 or param2 along with the event trigger. Inside the script action, you simply need to process the desired output.

 

Please refer to https://www.servicenow.com/docs/bundle/xanadu-build-workflows/page/administer/platform-events/refere... to know more about script actions. 

Harshit Sharma1
ServiceNow Employee
ServiceNow Employee

Thanks for the reply. How do you trigger an event from a flow action? Can you let me know the syntax or reference for it?

@Harshit Sharma1 I am assuming your flow action uses a script, if this assumption is true you can simply put 

gs.eventQueue('event_name',current,current.number,gs.getUserName());

To trigger the event.

Hi Sandeep,

Thank you for your information, it's very helpful for me. However, I have another concern, could you help me with this?

 

I'm successful to run parallel 2 API call as your guide above, and I'm able to get the output using event and script action. However, I want to store that data into user's session or pass that data into UI page to show it for user. Is it possible? I have tried the gs.getSession().putClientData() but it didn't work, it store in system session not current user's session.