Script Include and Client Script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2024 03:09 AM
There is a variable on service catalog that is targeting to location [cmn_location] table, so If requested for changes location changes too depending on requested for, so if requested for belongs from USA country and his location is "Mesa" then a select box choice should be "True" but if requested for belongs from USA country and his location is "San Diego" then a select box choice should be "false".
I tried creating script include and calling in client script but didnt worked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2024 03:38 AM
Hello @shatakshi10 ,
Could you please elaborate more on your requirement? What should happen if both of the given conditions are not met?
Additionally, could you share what you have tried so far?
Thanks,
Ashish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2024 08:13 AM
Main Concern is about these options ,
I have a select box from which choices needs to be reflected based on Location
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2024 03:40 AM - edited ‎12-20-2024 03:55 AM
@shatakshi10
Calling a Script Include in an OnChange Catalog Client Script should work in this scenario. Please share what you've tried so far to ensure we can provide more accurate and helpful answers.
Client Script to set location of user - ServiceNow Community
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-24-2024 12:32 AM
getLocation: function() {
var locsysid = this.getParameter('sysparm_loc_sysid');
var gr = new GlideRecord("cmn_location");
gr.addQuery('sys_id', locsysid);
gr.addEncodedQuery("country=Mexico^ORcountry=Canada^ORcountry=United States of America^nameLIKERemote");
gr.query();
if (gr.next()) {
return 'true';
} else {
return 'false';
}
var ga = new GlideAjax('restrictingOptionBasedOnLocation');
ga.addParam('sysparm_name', 'getLocation');
ga.addParam('sysparm_loc_sysid', newValue);
ga.getXML(callBackFunction);
function callBackFunction(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
alert(answer)
if (answer == 'true') {
g_form.removeOption();
g_form.addOption();
}
else{ g_form.addOption();
}
}