How to confirm the assignment group type of a user in a business rule condition?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2021 02:23 PM
Hello!
I am wondering how to best confirm that a user's assignment group's group type is certain type. Perhaps this is a custom field on the sys_user_group table my company has added, as I do not see it on my PDI when I went and looked. Thinking I may have to do a GlideRecord look up, but am wondering if I can instead simply create a condition in the business rule. We want the business rule to run when a user is not part of a certain group type.
Thanks!
Best,
Dan
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2021 04:52 PM
Hi Dan,
Out of box there is a List field named Type on the sys_user_group table, but there is not an Assignment group field on the sys_user table. If you have a custom field Assignment group on sys_user and it is a Reference to sys_user_group, then you should be able to get away with building Filter Conditions for when to run the BR. Since Type is on the group table and you're running the BR on the user table, the key is that you need a field which is a reference to Group on the User table in order to use Type (or any other fields on the Group table) in the conditions. So just try it and see if you see the fields you need. You would probably want something like Assignment group changes as the first condition - unless you want to check this every time a sys_user record is inserted and/or updated. To get to Type, in the field list on the condition builder at the bottom choose Show Related Fields then drop down the field list again and you should a choice something like Assignment group -> Assignment group fields. If you select that, then drop down the field list again again you'll see the sys_user_group fields indented underneath .Assignment group>>Assignment group fields. Now you would select Type does not contain itil - or whatever the name of the type is you're wanting to trigger on the absence of. Type is a List field which means it can contain multiple values which is why the operator selection is 'contains/does not contain' instead of 'is/is not'. If your structure is different than this, Filter Conditions may not work.
FYI you can easily track down which fields are on which tables by right-clicking on a field label then choosing Show - field name. If you're on the User form, and a field says something like sys_user_group.type, then the field resides on the Group table, but is being displayed on the User form. Any custom fields should be named starting with u_, but that enforcement started in a release not terribly long ago, so I think it's possible to have a 'vintage' custom field that doesn't follow this naming convention.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2021 09:12 PM
I wasn't clear if you wanted to know how to check against the incidents current asignment group, or if you wanted to check to see if the assigned to user was a member of any group that happened to be of that particular type. So, I covered both scenerios for you in this video.
Here is the script include that I created in the second scenario:
var Check_User_group_types = Class.create();
Check_User_group_types.prototype = {
initialize: function() {},
chkType: function(usr, type) {
var gr = new GlideRecord("sys_user_grmember");
//check to see if the group type named 'Test Type' is associated with one of the user's groups
/////////////////////////////////////////////////////////////////////////////////////////////////
gr.addEncodedQuery('group.typeLIKEdd57691d1b122010fd53877ddc4bcbd1'); //replace this sys_id with the type you want to look for
gr.addQuery("user", usr);
gr.query();
if (gr.next()) {
return true;
}
return false;
},
type: 'Check_User_group_types'
};
And I called this in the BR condition field using:
new Check_User_group_types().chkType(current.assigned_to,'dd57691d1b122010fd53877ddc4bcbd1')
The sys ID on the second parameter is the sys_id of the group type you are looing for.
https://youtube.com/watch?v=zYi8KhP9SUk

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2021 08:23 AM
Thank you!! Just to let you know, I meant if to check if the user is a member of any group that has a specific type (your second scenario). Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-12-2021 11:05 AM
Great. Sounds like the question is answered then? If so, please mark it as answered to that others who view this will benefit as well. Have a great day!
https://youtube.com/watch?v=zYi8KhP9SUk