onSubmit Client Script with getXMLWait()

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2023 06:36 AM
I am working on a couple of requirements on Incident Table where validation is required before submission.
1. If the priority is critical, I need to make attachment mandatory. (Stop submit if no attachment)
2. If the caller is a non-employee, they should be stopped from submitting the Incident.
Can I use getXMLWait() here, or is it not suitable?
If not will how will I accomplish the same functionality using getXML?
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2023 06:44 AM
Hello @Kartik Gopal ,
Technically speaking, getXMLWait() is a Synchronous call and getXML() is aSynchronous.
- getXMLWait() is used when you want to halt processing until the results are returned. This will halt everything and wait for it to finish and return the results
As the current situation is where we do want to wait for the results before continuing (even though it will take a few seconds). However, for the most part, we use getXML and a callback function for the vast majority of our uses.
When you are trying to retrieve value of the variable.after getting value then only we can proceed next step like comparing it with user input.In such scenarios will use getxmwait().
Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2023 07:18 AM
If my answer help please mark it as accepted solution and close the thread.
Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-22-2023 06:45 AM
Hi @Kartik Gopal ,
It is good to use getXMLWait() as you specified you are doing the validation in onSubmit client script. getXMLWait() will make synchronous call so the execution waits for response and the form will not be submitted. Where as getXML() will make asynchronous call and will not wait for response which might not be suitable for you.
Anvesh