How to insert a condition in a User Criteria from two different tables
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-14-2024 11:44 AM
(function isAllowed() {
var gr = new GlideRecord('sys_user');
gr.addQuery('sys_id', 'sysparm_user');
gr.addQuery('active', 'true');
gr.addQuery('sso_source', gs.getProperty('*SOME PROPERTY*'));
gr.query();
if (gr.hasNext()) {
var usergr = new GlideRecord('sys_user_has_role');
usergr.addQuery('state', 'active');
usergr.addQuery('role', '*ROLES*');
usergr.query();
return usergr.next();
}
})();
How do I use the gliderecord for two different table?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-14-2024 12:52 PM
Hi @pjftenorio,
Why are you querying the [sys_user] and [sys_user_has_role] tables?
Can't you just query the [sys_user_has_role] table?
Cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2024 02:18 AM
Hi James, I have a custom field in the sys_user table which is the SSO ID of a user, then I need to get the role from that user in sys_user_has_role table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-15-2024 01:06 PM
So you are checking if the current user's SSO ID is equivalent to a system property and if the user has a certain role?
If so, can't you do something like the following instead?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-14-2024 12:55 PM
Hi,
I am assuming your requirement is. "If the user fits xyz requirement in sys_user table and also fits the abc requirement in sys_user_has_role table; then the user pass the user criteria", yes?