- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi All,
I want to display entitlements based on lob and category field selection. These entitlements are coming from u_platform_region table. I have used a advanced reference qualifier with below query which is working fine.
Condition : 'u_domain ='+ current.variables.lob+ '^u_requesttype ='+current.variables.category;
The new requirement is to include below condition as well along with current condition based on the user country
| Excluding China | not visible to China else visible to all | |
| Including China | visible to China | |
| NA | visible to all |
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
try this. enhance as per your requirement like picking country, sysids of the region if region is reference field etc
javascript: var query;
var grUser = new GlideRecord('sys_user');
if (grUser.get(gs.getUserID())) {
var country = grUser.country.toString(); // Adjust if using a custom field like u_country
query = 'u_domain=' + current.variables.lob +
'^u_requesttype=' + current.variables.category;
if (country == 'China') {
query += '^u_regionINIncludingChina,NA';
} else {
query += '^u_regionINExcludingChina,NA';
}
query;
}
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Hi @Ankita9793
Try this,
1: Create a Script Include
- Name: EntitlementUtils
- Client callable: Checked (true)
var EntitlementUtils = Class.create();
EntitlementUtils.prototype = {
initialize: function() {},
getEntitlements: function(lob, category) {
var query = 'u_domain=' + lob + '^u_requesttype=' + category;
var userRec = gs.getUser().getRecord();
var userCountry = userRec.getValue('country');
if (userCountry == 'China') {
query += '^u_region=China';
}
else if (userCountry == 'Excluding China') {
query += '^u_region!=China';
}
else {
// 'Else visible to all' requirement -> Do not append any restriction
}
return query;
},
type: 'EntitlementUtils'
};
2: Configure the Variable Reference Qualifier
javascript: new EntitlementUtils().getEntitlements(current.variables.lob, current.variables.category);
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
try this. enhance as per your requirement like picking country, sysids of the region if region is reference field etc
javascript: var query;
var grUser = new GlideRecord('sys_user');
if (grUser.get(gs.getUserID())) {
var country = grUser.country.toString(); // Adjust if using a custom field like u_country
query = 'u_domain=' + current.variables.lob +
'^u_requesttype=' + current.variables.category;
if (country == 'China') {
query += '^u_regionINIncludingChina,NA';
} else {
query += '^u_regionINExcludingChina,NA';
}
query;
}
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Hi @Ankita9793
Try this,
1: Create a Script Include
- Name: EntitlementUtils
- Client callable: Checked (true)
var EntitlementUtils = Class.create();
EntitlementUtils.prototype = {
initialize: function() {},
getEntitlements: function(lob, category) {
var query = 'u_domain=' + lob + '^u_requesttype=' + category;
var userRec = gs.getUser().getRecord();
var userCountry = userRec.getValue('country');
if (userCountry == 'China') {
query += '^u_region=China';
}
else if (userCountry == 'Excluding China') {
query += '^u_region!=China';
}
else {
// 'Else visible to all' requirement -> Do not append any restriction
}
return query;
},
type: 'EntitlementUtils'
};
2: Configure the Variable Reference Qualifier
javascript: new EntitlementUtils().getEntitlements(current.variables.lob, current.variables.category);
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti