Service Catalog workflow with country restrictions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2023 06:53 AM
This is causing the Requested Item records to not be found in the service catalog workflows because of the records being restricted by country. I am looking for some guidance to solve this issue. Any ideas???

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2023 07:38 AM
Hi,
You need to apply the before query business rule on each table and conditions for specific table only. you will not get table name (taskType = incident, sc_request etc in before query).
I doubt it is going into the if conditions and your filter condition is set as default (LAST ELSE PART Always).
Also make sure your BR is only running by check gs.isInteractive()
Below is sample script for an incident table:
(function executeRule(current, previous /*null when async*/ ) {
if (!gs.hasRole('admin') && gs.isInteractive()) {
var userCountry = "";
var query = "";
var currentUser = gs.getUserID();
var userGR = new GlideRecord('sys_user');
if (userGR.get(currentUser)) {
userCountry = userGR.location.country + '';
}
var userCountrySm = userCountry.toLowerCase();
if (userCountrySm !== 'us' && userCountrySm !== 'united states' && userCountrySm !== 'usa' && userCountrySm !== 'united states of america') {
query = "ref_incident.caller_id.location.country=" + userCountry;
current.addEncodedQuery(query);
}
}
})(current, previous)
Note: Also make sure to include your login in existing Before Query BR (if any) for particular table. Creating multiple Before Query BR will not work as expected. If you are creating multiple BR then set proper order .
Thanks
Anil Lande