onSubmit Client Script with getXMLWait()

Kartik Gopal
Tera Contributor

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.

 

3 REPLIES 3

Nayan  Dhamane
Kilo Sage
Kilo Sage

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().

If my answer solved your issue, please mark my answer as Correct & Helpful based on the Impact

Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.

If my answer help please mark it as accepted solution and close the thread.

If my answer solved your issue, please mark my answer as Correct & Helpful based on the Impact

Best Regards,
Nayan Dhamane
ServiceNow Community Rising Star 2023.

AnveshKumar M
Tera Sage
Tera Sage

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.

 

 

Thanks,
Anvesh