- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 01:14 AM
Hi Team, we have location field in incident form and request item form whenever location is updated then Region field also display and update based on location region for that How to create script please help.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 03:11 AM
Hi Rahul,
Thank you for your support,
I have below region list for example i have selected india in location field level then Asia need to display in region field level same way for all 3 region please tell me how to modify
Asia, America, Europe
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 03:30 AM
It will be working for all region!
Thanks and Regards,
Rahul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 02:15 AM
Hi @Aruna10 ,
Create a script include:
var GetLocationDetails = Class.create();
GetLocationDetails.prototype = Object.extendsObject(AbstractAjaxProcessor, {
locDet: function(){
var loc = this.getParameter("sysparm_loc_det");
var gr = new GlideRecord("cmn_location");
gr.addQuery("sys_id",loc);
gr .query();
if(gr.next()){
var obj={
"region" : gr.region.toString(),
};
var data = new JSON().encode(obj);
return data;
},
type:'GetLocationDetails'
});
And a on change client script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var ga = new GlideAjax("GetLocationDetails");
ga.addParam("sysparm_name",'locDet');
ga.addParam("sysparm_loc_det",g_form.getValue("location"));
ga.getXML(testLoc);
function testLoc(response)
{
var answer = response.responseXML.documentElement.getAttribute("answer");
var returneddata = JSON.parse(answer);
g_form.setValue('u_region', returneddata.region);
}
}
Thanks and Regards,
Rahul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 03:11 AM
Hi Rahul,
Thank you for your support,
I have below region list for example i have selected india in location field level then Asia need to display in region field level same way for all 3 region please tell me how to modify
Asia, America, Europe
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 03:14 AM
Corretn me if I am wrong!
You want region only to be populated if region is aisa, america or europe?
Thanks and Regards,
Rahul
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 03:21 AM
Yes its Correct If incase we have selected location is Finland then region field level need to update "europe" like wise we need to do for those
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2023 03:24 AM
Is my script working fine?
Thanks and Regards,
Rahul