GetXMLWait vs GetXML

Johannes Mweli
Giga Guru

Hi ServiceNow Community Developers,

 

I keep hearing that GetXML() is good to use, best practice and recommended over GetXMLWait(). However I am wondering what do you do in a case where you need to wait for a response to come back in your script before you proceed.  Can you achieve that behavior with GetXML()? If so, how?

 

For instance,  let’s say you need to do a server side lookup before you submit your form. The submission depends on the value that will be returned by an AJAX call. If I use GetXML() my form always gets submitted before the response comes back and that is the behavior that I don’t want. On the other hand if I use GETXMLWait() I get the correct behavior because the client waits until the value that I need to check for before submitting the form is returned.

 

Basically what I am trying to figure out is if we are advised to use GetXML() instead of GetXMLWait() how do we then achieve the functionality that GetXMLWait() has especially where you need the value from server to use for processing downstream in your script.

 

I also read somewhere that GetXMLWait() is no longer supported however I am wondering for the life of me how does one then use GetXML() and get the same functionality like the one GetXMLWait() has.

 

Kindly advise please.

 

Thanks,

Johannes

1 REPLY 1

Chaitanya ILCR
Kilo Patron

Hi @Johannes Mweli ,

Refer this

https://www.servicenow.com/community/developer-articles/async-validation-in-onsubmit-catalog-client-...

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,

Chaitanya