onSubmit Client Script finishing before GlideAjax return value is processed

MBarrott
Mega Sage

I have a client script which will ultimately decide whether it will return false and display an error message to the user if certain criteria is not met. 

 

It initially just had a client-side check which worked perfectly, but now we need to check a condition server side for an additional check. 

 

The issue I'm running into is that despite the GlideAjax returning the correct value (T/F) and display the error, the client script still finishes and saves the record - feels like the client script is finishing before displaying all the alerts. 

 

Is there a way I can ensure the Client Script waits for all the server side conditions to return before running the last check to see whether it should process the onSubmit?

10 REPLIES 10

Bert_c1
Kilo Patron

You can have the CS wait for the server using 'ga.getAnswer()' if using 'ga.getXMLWait()' to sned the request to the server. See:

 

https://docs.servicenow.com/bundle/xanadu-api-reference/page/app-store/dev_portal/API_reference/Glid...

 

Search examples as DrewW mentions.