Can two seperate API calls performed in parallel in an onLoad client script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2022 03:47 AM
Hi all,
I have a catalog item. When the form is loaded I want to have two seperate API calls (different endpoints) to retrieve data and autopopulate the form. In particular, a client script that sends data to a script include and the script include performs the integration.
What is the best solution to this?
Should I have two seperate onLoad client scripts that make the API calls? In this case, the calls will be performed in parallel or sequentially??
Any ideas are welcomed 🙂
Thank you,
Smith.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2022 03:59 AM
Hi
You cannot force parallel execution on server side triggered from client side, as ServiceNow enforces session synchronization (session sync).
That means:
- Single active session per user pre browser
- Only a single transaction per session can be executed at once
- Multiple requests from the same session will run serially
-
on client side you cannot perform AJAX based requests to 3rd party system as your browser will block these cross domain requests.
So if you really need parallel requests you have to invest a bit more. My first idea is to create a Flow, add in that Flow parallel execution gateways and perform the REST requests in respective actions. After that you should join the individual Flow paths and merge the results for sending back to client.
And on client-side, you can trigger a Flow execution via script.
Mentioned here.
Mark my answer correct & Helpful, if Applicable.
Thanks,
Sandeep

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2022 09:03 PM
Hi
Glad to see my answer helped you, Kindly mark the answer as Correct & Helpful both such that others can get help.
Thanks,
Sandeep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-01-2022 04:01 AM
Hello,
On what basis these 2 API Calls are made ?
Are they are dependent on some fields or something else.
Can you please explain your requirement?
Thanks