- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2015 11:20 PM
Requirement--- for sev1 and sev2 incidents, when you select the value in preliminary caused by business segment (i.e nothing but company value) if the selected value has sev1 true for sev1 incident then problem assigned to filed should get mandatory same way, if the company table has sev1 as false then problem assigned to should not be mandatory.
for sev2 incident if the selected company has sev2 value as true then problem assigned to field should get mandatory. if it is false then no mandatory.
(note: Company table has sev1 and sev2 values for each record )
Client script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading) {
return;
}
var nb=g_form.getValue('number');
var company1=g_form.getValue('u_preliminary_caused_by');
var sev=g_form.getValue('severity');
var gpc = new GlideAjax('Compseverity');
gpc.addParam('sysparm_name','severitychk');
gpc.addParam('sysparm_sysid',nb);
gpc.addParam('sysparm_preliminary',company1);
gpc.addParam('sysparm_severity',sev);
gpc.getXML(getresults);
function getresults(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
if(answer=='true')
{
g_form.setMandatory('u_problem_owner',true);
}
else
{
g_form.setMandatory('u_problem_owner',false);
}
}
}
script include:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading) {
return;
}
var nb=g_form.getValue('number');
var company1=g_form.getValue('u_preliminary_caused_by');
var sev=g_form.getValue('severity');
var gpc = new GlideAjax('Compseverity');
gpc.addParam('sysparm_name','severitychk');
gpc.addParam('sysparm_sysid',nb);
gpc.addParam('sysparm_preliminary',company1);
gpc.addParam('sysparm_severity',sev);
gpc.getXML(getresults);
function getresults(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer);
if(answer=='true')
{
g_form.setMandatory('u_problem_owner',true);
}
else
{
g_form.setMandatory('u_problem_owner',false);
}
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2015 11:39 PM
Hi Tejashree,
why you are using Script include? if u are just checking value from any reference field(like sev1 field on company table) from incident form. u can use g_form.getReference().
see this page GlideForm (g form) - ServiceNow Wiki
if u cant make it working then tell me more about table structure then I can write script for u.
****hit helpful/like/correct if it helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2015 11:39 PM
Hi Tejashree,
why you are using Script include? if u are just checking value from any reference field(like sev1 field on company table) from incident form. u can use g_form.getReference().
see this page GlideForm (g form) - ServiceNow Wiki
if u cant make it working then tell me more about table structure then I can write script for u.
****hit helpful/like/correct if it helps

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2015 01:20 AM
Hi Tejashree,
I see your script include code and client script code are same.
Make sure your script include file name is "Compseverity", function name is "severitychk" and you have checked "client callable"
If you still not able to get the expected result pass the script include code, let me try on it
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2015 01:31 AM
Function name is case sensitive and make sure client callable is true.
You can also add log in script include. It might be calling the script include but not returning any value.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2015 01:45 AM
Thanks all for the help.