Create Advanced Script on User Criteria for locations
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2020 08:49 PM
Hello,
I am trying to create an Advanced Script for User Criteria to make a content item available for certain locations. There are about 100 locations that the content item should be available for. Below is the script that I am using and is not working.
checkCondition();
function checkCondition() {
var queryString = 'city=Sacramento^ORcity=Wichita';
var gr = new GlideRecord('cmn_location');
gr.addEncodedQuery(queryString);
gr.query();
if (gr.hasrNext()) {
answer = true;
}
return false;
}
Any idea on what I am doing wrong?
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2020 10:03 PM
Hi,
Usually the User Criteria evaluates for logged in user and if it satisfied it shows the catalog item
if the location of the user has empty City then it doesn't make sense having User Criteria
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2020 10:29 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-08-2020 10:33 PM
Hi,
yes he rightly said. Ideally your users in sys_user table should have locations associated to their profile and location table should have city and all other information
If everything is setup correctly i.e. users have location and location have city; then no need of advance user criteria directly you can give the locations for which this catalog item should be visible
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2020 05:48 AM
Is there a test script I can use to see what data is being pulled back?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-09-2020 05:57 AM
Hi,
How is your user table loaded? Is somebody manually loading the data using some template using data source. Do they have location value populated
Check LDAP is configured in the instance which might be pulling the data
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader