change GlideAjax method from GetXML() to GetXMLWait()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Hi @sureshp89882164 ,
For a client-side onChange script that displays an alert, using getXMLWait() is generally not the recommended best practice. The current getXML() approach, which is asynchronous, is better for user experience.
getXML() vs. getXMLWait() for your scenario:
1. getXML() (Asynchronous)
- How it works: The script sends a request to the server and continues processing without waiting for the response. When the response is received, the callback function (responseParse in your code) is executed.
- Pros: The UI remains responsive. The user can continue to interact with the form while the server-side lookup is happening.
- Cons: Since the script doesn't pause, the alert will pop up after the user has already changed the assignment group. If the user clicks "Save" very quickly, the alert might appear too late to prevent the re-assignment.
2. getXMLWait() (Synchronous)
- How it works: The script pauses and freezes the user interface until a response is received from the server.
- Pros: You are guaranteed to get the server's response before the rest of the client-side code continues. This means the alert will fire immediately after the value change, and you could add logic to prevent form submission.
- Cons: This is considered bad practice because it freezes the UI, creating a poor user experience, especially on slow connections. It is generally discouraged by ServiceNow.
If this solution helps you then, mark it as accepted solution ✔️ and give thumbs up 👍!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Here is the SN documentation you can check out for the code: https://www.servicenow.com/docs/csh?topicname=c_GlideAjaxAPI.html&version=latest