Need to populate location field based on the country selection
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2018 07:04 PM
Hi all,
I have a requirement where in we need to populate the location (reference to cmn_location) value based on the selection of country (reference to core_country). If for example countries Japan and China are selected then on the locations that are active under these countries should be available for selection in location field.
I got to know that we need to achieve this through script include and advance reference qualifier since the location field is a reference field.
Could you please help me with the script, Im fairly new to scripting and would be a great learning for me.
Thanks in advance.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2018 09:59 PM
Hi
Here the exact solution as per your requirement:-
getCountry1 : function ()
{
var sys_id_list=[];
var cou;
var a=current.variables.u_select_country.getDisplayValue();
var gr1=new GlideRecord('cmn_location');
gr1.addQuery('country',a);
gr1.query();
while(gr1.next())
{
sys_id_list.push(gr1.getValue('sys_id'));
}
return 'sys_idIN'+sys_id_list.toString();
},
paste the code in your script include like:- 'getCountryLocation'
call the script include name and method in your location field in reference qualifier section see the below screenshot:-
Here the form layout:-
Also, see the attached attachment
Regards,
PKG
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2018 10:41 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2018 10:42 PM
Hi
You called the script include wrong :-
javascript : new getCountryLocation().getCountry1();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2018 10:50 PM
I have changed it but still it is not working as expected.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2018 10:50 PM
Hi
Your fields is in what scope? because your script include scope is human resource. So please make sure the scope.