
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2022 09:27 AM
Hi,
I am having a trouble with request submiting even if my OnChange don't finished the script execution. Below my scenario:
1. I have a script include that calls an external API and returns me some data
2. I have a catalog client script OnChange() that runs on Service Portal when I change a value from a certain variable from the catalog item form. This catalog client script, calls a GlideAjax to use the data of the API that I specified above. Depending on the response of the API/GlideAjax, the script of OnChange do some stuff on my variables (such as clear variables value or set variables values)
3. When I tested if the scripts are working on the catalog item portal's form I found something wrong. The scripts were working as expected when I changed the variable value that triggers the OnChange catalog client script and clicked out the variable or clicked to fill another variable from the form. But when I fill the variable that triggers the OnChange client script and after that click directly on Submit button from the catalog item form, sometimes the OnChange script works, but sometimes no and the request is submitted without the OnChange script finish the execution.
Can you help me to understand why is it happening ?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2022 09:40 AM
Is the getXMLWait() not working in onchange client script. I believe it should work?
Interesting. Make the field which you are populating mandatory? will that not do the trick as with out any value in that field it user will not be able to submit?
OR
In the onsubmit client script just check if the field is still empty if yes return false else return true.
Let me know what you think of the above.
Please mark my answer as correct based on Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2022 09:40 AM
Is the getXMLWait() not working in onchange client script. I believe it should work?
Interesting. Make the field which you are populating mandatory? will that not do the trick as with out any value in that field it user will not be able to submit?
OR
In the onsubmit client script just check if the field is still empty if yes return false else return true.
Let me know what you think of the above.
Please mark my answer as correct based on Impact.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2022 09:47 AM
I tried to use getXMLWait(), but seems that this method doesn't work on Service Portal.
The variables of the form are already mandatory, but I still face the same issue. Seems that if I change the value of the variable that triggers the OnChange client script and after that click directly on Submit button of the catalog item sometimes the OnChange client script doens't finished to execute and the REQ submitted is sent with old/wrong values on the variables.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2022 10:03 AM
Hello,
As I had suggested earlier you may try the below:-
In the onsubmit client script just check if the field is still empty if yes return false else return true.
Please mark my answer as correct based on Impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2022 09:56 AM
That sounds like normal behavior. If you tell the browser to submit the form, it doesn't care what JavaScript is doing. Saurav's suggestion about using an onSubmit script to, in effect, wait for the API result sounds like it would work.