- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2020 12:46 AM
Hi
I want a user criteria to both match user group and a location that is on the user.
But this doesn't work. Do I have to script? I am novice at scripting, How would such a script look?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2020 07:48 AM
Hi,
I would encourage to have step by step debug
1) check if member of Hardware is able to access the catalog
Keep Script as: Test with user
answer = gs.getUser().isMemberOf('Hardware');
Next
2) check if user's location condition is satisfied
Keep Script as: Test with user having that location
answer = ifScript();
function ifScript(){
var user = new GlideRecord('sys_user');
user.addQuery('sys_id', gs.getUserID());
user.addQuery('location', '25ab9d720a0a0bb300793d3a6b891f82');
user.query();
var locationValid = user.hasNext();
return locationValid;
}
3) Now combine both the codes and check by adding logs
If my answer solved your issue, please mark my answer as ✅ Correct & 👍Helpful based on the Impact.
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
06-18-2020 01:14 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2020 12:57 AM
Hi,
since you have checkbox of Match ALL
it would check all conditions for satisfying
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
06-18-2020 01:15 AM
Match all doesnt seem to work for these 2 combination. I can impersonate someone with Hardware but with another location and incorrect fully still access it
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-18-2020 01:44 AM
Hi,
please update script as below
answer = isValid();
function isValid(){
var isMember = gs.getUser().isMemberOf('Hardware');
var arr = ['locationSysId1','locationSysId2','locationSysId3'];
var user = new GlideRecord('sys_user');
user.addQuery('sys_id', gs.getUserID());
user.addQuery('location','IN', arr);
user.query();
var locationValid = user.hasNext();
if(isMember == true && locationValid == true)
return true;
else
return false;
}
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
06-18-2020 02:01 AM
It is only for one single location. I tried it but it did not work.