- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2020 12:14 PM
In our instance, we have a custom field (reference to a custom table called Org). This field is on the Department table and is dot-walked to from almost all our ITSM processes.
We need to build a user criteria (Available For) based on this this custom field (Org). This user criteria will be used in the portal Announcements.
We added the Org field to the User Criteria form but we are not able to make it work. I am sure somewhere in some script we have to update the logic as to where it should be looking to validate if the user passes this Org criteria or not.
Where exactly should we be looking to add this logic of the newly added User Criteria field? Thanks.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2020 12:44 PM
I don't believe that you could update the internal ServiceNow logic to include that field directly. What you could do is use the advanced option in the user criteria and then script your check.
You would want to write a function that returns a true or false based on the conditions that you want.
In order to lookup the user, you would use the "magic" variable user_id.
So, something like this:
checkCondition();
function checkCondition() {
var user = new GlideRecord('sys_user');
user.get(user_id);
if(user.department.<your_custom_field> == 'whatevervalue') {
return true;
}
return false;
}
If the function returns true, the user will have access, otherwise they will not.
If this was helpful or correct, please be kind and click appropriately!
Michael Jones - Proud member of the CloudPires Team!
Michael D. Jones
Proud member of the GlideFast Consulting Team!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-03-2020 12:44 PM
I don't believe that you could update the internal ServiceNow logic to include that field directly. What you could do is use the advanced option in the user criteria and then script your check.
You would want to write a function that returns a true or false based on the conditions that you want.
In order to lookup the user, you would use the "magic" variable user_id.
So, something like this:
checkCondition();
function checkCondition() {
var user = new GlideRecord('sys_user');
user.get(user_id);
if(user.department.<your_custom_field> == 'whatevervalue') {
return true;
}
return false;
}
If the function returns true, the user will have access, otherwise they will not.
If this was helpful or correct, please be kind and click appropriately!
Michael Jones - Proud member of the CloudPires Team!
Michael D. Jones
Proud member of the GlideFast Consulting Team!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-28-2021 10:24 AM
For people not getting consistent results when testing try clearing the system cache (by searching cache.do in the application navigator) after updating the user records...took me a while to figure out why it was sometimes working and sometimes not.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2021 09:54 PM
Hello Winston,
Good Day! Thanks a lot it helps 🙂
Thanks,
Priyanka R
