onChange client script triggered twice
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2014 10:11 AM
My script resets the value of the field to null if the server returns a negative result, and it appears that that reset is causing the onChange function to be triggered again. Anyone else have this problem? Any suggestions to resolve?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2014 10:14 AM
Hi Daniel,
Check if there's any looping going on in this case.
Like onChange of a field you're setting some other field value. And on change of that other field, your field is getting changed.
Such things might cause the issue you're facing.
Thanks,
Mandar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2014 10:20 AM
I deactivated all other client scripts for this form, and this is the only field affected by this script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2014 10:26 AM
Hi Daniel,
Make use of parameters oldValue and newValue in onChange Client script:
For Eg:
if(oldValue != newValue && newValue != null)
If it stiil persists,for more clarity can you paste you Cleint script.
Thanks,
Darshan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-14-2014 10:31 AM
Hi Darshan,
The client script is pasted below.
Darshan and Mandar, thanks for your input!
-Dan
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading){
return;
}
var costInfo = checkSAPInfo();
var costObject = g_form.getValue('u_cost_object');
var deptID = g_form.getReference('u_requesting_department');
var deptNumber = deptID.name;
if (costObject!='' && deptNumber!=''){
if (costInfo != "true"){
alert("This is not a valid cost object. Please contact your business officer to obtain a valid cost object.");
g_form.setValue('u_cost_object','');
}
else{}
}
}
function checkSAPInfo(){
var costObject = g_form.getValue('u_cost_object');
var deptID = g_form.getReference('u_requesting_department');
var deptNumber = deptID.name;
var ga = new GlideAjax('sapInfo'); // the Script Include object name
ga.addParam('sysparm_name','getRecordByID'); // the function on the server to call
ga.addParam('sysparm_svc', "SAPCostObject");
ga.addParam('sysparm_method', "wsSoap12.ValidateDepartmentAndCostObject");
ga.addParam('sysparm_node', "ValidateDepartmentAndCostObjectResponse");
ga.addParam('sysparm_arg1Name', "departmentNumber");
ga.addParam('sysparm_arg1Value', deptNumber);
ga.addParam('sysparm_arg2Name', "costObjectCode");
ga.addParam('sysparm_arg2Value', costObject);
ga.getXMLWait();
return(ga.getAnswer());
}