How to display locations based on country in catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2023 01:44 PM - edited 09-04-2023 01:44 PM
Hello everyone can someone help me figure out why this doesn't work i want to display locations based on value put in country
i have two fields : location and country
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2023 03:33 PM
Thanks - I was using the cmn_location table, so that explains the difference. For the core_country table, it will be using the sys_id as the selected value so you'll want to update Ref Qual on the Location variable to:
current.variables.country.getDisplayValue();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2023 03:14 AM
Works now thanks @Craig Gruwell for my Location field i want to remove a location from showing in the list how can i do that?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-05-2023 04:43 AM
You'll want to append that condition to your Ref Qual, such as:
'country=' + current.variables.country + '^name!=<name of country to exclude>';
or
'country=' + current.variables.country + '^sys_id!=<sys_id of country to exclude>';
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2023 03:39 PM
Actually that might partially work. The display values for the core_country table may differ slightly with the Country values in the cmn_location table. It might work for some but not others. For example, core_country uses "United States of America" but the Country field in the Location table uses "USA". You might want to use the cmn_location table instead of the core_county table to avoid this issue. Refer to screenshot if that helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-04-2023 10:01 PM
Hello yoli1,
It depends upon type of variable you used.
Have you used "Country" variable as "Reference" ?
If yes then in your reference qualifier -
javascript:"u_country=" + current.variables.country;
current.variables.country : you will get the sys_id
so in location table if "u_country" is reference field then it should work else it will not work.
ServiceNow Developer
I know one thing, and that is that I know nothing.
- Socrates