Aynchronous GlideAjax call is too slow and displays wrong data on the form

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-24-2015 07:47 AM
Hello all,
We are using async GlideAjax calls on the Incident form.
When the user changes a combination of 2 fields on the form, we have an 2 on change client scripts which use async GlideAjax and the response we receive is used to set the value in the 3rd field.
When the user changes the value in quick succession, we see old data displayed.
The quick solution is to use getXMLWait but that would hamper the user expererience.
We even tried using showLoadingDialog and hideLoadingDialog but it seems these are not displayed (using chrome and IE).
Kindly suggest an alternate way to tackle this.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2015 02:32 PM
Bump
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2015 04:08 PM
When the first onChange Client Script is triggered, can you disable the field(s) when you call the GlideAjax, then re-enable them when you get the response? It means they can't change the fields while the server call is happening, but at least it won't display incorrect information.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2015 06:17 PM
You could implement your requirement using the pattern below:
Have this code on 'field1' and 'field2' onChange, substituting conditionsSatisfied with your requirement.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if(conditionsSatisfied) {
DoAjax();
}
Have this code on your table onLoad, making the fields read only until the GlideAjax call returns.
This will prevent users from messing it all up
function onLoad() {
}
function DoAjax() {
var ga = new GlideAjax('HelloWorld');
ga.addParam('sysparm_name','helloWorld');
ga.addParam('sysparm_user_name',"Bob");
g_form.setReadOnly('field1',true);
g_form.setReadOnly('field2',true);
ga.getXML(HelloWorldParse);
}
function HelloWorldParse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
g_form.setReadOnly('field1',false);
g_form.setReadOnly('field2',false);
}
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-26-2015 05:47 PM
Does this answer your question? Or are you looking for something else?
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022