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 08:41 PM
Hi,
Please write the below code in the script include:-
function getCountry()
{
var sys_id_list=[];
var cou;
var a=current.variables.u_requested_for.country;
var gr1=new GlideRecord('sys_user');
gr1.addQuery('country',a);
gr1.query();
while(gr1.next())
{
sys_id_list.push(gr1.getValue('sys_id'));
}
return 'sys_idIN'+sys_id_list;
}
and call the script include a name in the reference qualifier section
and also try the below code in your country field:-
javascript: country=current.field_name.getDisplayValue();
Regards
PKG
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2018 09:14 PM
We need to take the country value from the selected country in the "country" field not from the user country.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2018 09:26 PM
Okay, Just change the table name.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2018 09:30 PM
there is another field 'u_country' whatever the country selected in that field, location field should only show the locations present from the countries selected in the countries field which is a slush bucket.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2018 09:33 PM
Okay, I will give the exact solution next couple of minutes.