- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
Hi ServiceNow Community Developers
I have the following use case: I am in a scoped application. I am using the onsubmit client script that has the getXML() function. There are fields on the form that I am submitting that needs to be populated by the response of the getXML() function before the form can be submitted. The issue I am running into though is that since getXML() is async it does not wait for the response to come back from the server, it issues a call to the server and then goes ahead and submit the form before the response comes back. As a result of this behavior some fields are submitted without getting populated.
Would you guys please advise if there is a way I can overcome this. In other words is there a way to pause the form submission until the fields that needs to populated by the response from getXML() function have been populated.
Kindly advise please
Thanks,
Johannes
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago - last edited 3 hours ago
@Johannes Mweli SN has created a support article explaining this and how to make async call in onsubmit
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0783579
NOTE: This does not work in catalog client script, as per my discussion with HI support.
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
You can use getXMLWait() so that all fields get populated from the server. If you still want to use getXML() then you can put a condition that if required fields that needed to be populated form server if empty then use 'return false' to prevent the form submission.
Regards,
Sourabh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Hi Sourabh,
getXMLWait() does not work in a scoped application, that's why I am using getXML().
Thanks,
Johannes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago - last edited 3 hours ago
@Johannes Mweli SN has created a support article explaining this and how to make async call in onsubmit
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0783579
NOTE: This does not work in catalog client script, as per my discussion with HI support.
Raghav
MVP 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago