- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2015 06:46 AM
Hi All,
I have written a client callable script include to set some reference field values on SRM form.
But whenever script include returns 'undefined' value the reference field values are setting with some value and the color of the field is changed to green even though the filed is empty. Please see the below screen shot
Please let me know if you have any idea on this
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-05-2015 10:13 PM
I fixed this issue by modifying the client side script.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading) {
return;
}
if (newValue != '')
{
locationValues(newValue);
}
else{
if(g_form.getValue('location1') != "")
g_form.setValue('location1',"");
if(g_form.getValue('location2') != "")
g_form.setValue('location2',"");
if(g_form.getValue('location3') != "")
g_form.setValue('location3',"");
if(g_form.getValue('location4') != "")
g_form.setValue('location4',"");
}
}
function locationValues(newValue){
var ajax = new GlideAjax('SiteContactChange2');
ajax.addParam('sysparm_name','getSiiteContact2');
ajax.addParam('sysparm_id2',newValue);
ajax.getXML(getResult);
}
function getResult(serverResponse){
var result = serverResponse.responseXML.getElementsByTagName("result");
var locat1 = result[0].getAttribute("loc1");
g_form.setValue('location1',locat1);
var locat2 = result[0].getAttribute("loc2");
if(locat2 != "undefined"){
g_form.setValue('location2',locat2);
}
else
{
if(g_form.getValue('location2') != "")
g_form.setValue('location2',"");
if(g_form.getValue('location3') != "")
g_form.setValue('location3',"");
if(g_form.getValue('location4') != "")
g_form.setValue('location4',"");
return;
}
var locat3 = result[0].getAttribute("loc3");
if(locat3!= "undefined"){
g_form.setValue('location3',locat3);
}
else
{
if(g_form.getValue('location3') != "")
g_form.setValue('location3',"");
if(g_form.getValue('location4') != "")
g_form.setValue('location4',"");
return;
}
var locat4 = result[0].getAttribute("loc4");
if(locat4!= "undefined"){
g_form.setValue('location4',locat4);
}
else
{
if(g_form.getValue('location4') != "")
g_form.setValue('location4',"");
return;
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2015 07:03 AM
Hi Md,
It sets the blank value returned from the script include. You can get the value on the client editor to check the same.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2015 08:20 AM
'By using if condition on client side I checked whether the value is 'undefined' or not, but issue here is whenever the 'name' field on SRM form changes the script include will run and it should set the values.
It is working as expected on first time but when I changed the name field then it is not working as expected if the script inclide returns 'undefined' value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2015 08:31 AM
What is the expected behavior when the script returns undefined?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-01-2015 12:10 AM
When it returns undefined value then field color is changing to green color even though the field is empty