Hi Team, we have location field in incident form and request item  form whenever location is updated

Aruna10
Tera Expert

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.

2 ACCEPTED SOLUTIONS

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

View solution in original post

It will be working for all region!

Please mark my response correct/helpful as applicable!
Thanks and Regards,
Rahul

View solution in original post

11 REPLIES 11

Rahul Talreja
Mega Sage
Mega Sage

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);
 }
}
Please mark my response correct/helpful as applicable!
Thanks and Regards,
Rahul

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

Corretn me if I am wrong!
You want region only to be populated if region is aisa, america or europe?

Please mark my response correct/helpful as applicable!
Thanks and Regards,
Rahul

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

Is my script working fine?

Please mark my response correct/helpful as applicable!
Thanks and Regards,
Rahul