- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2024 05:11 AM
Hello,
I have been asked to 'lock down' an assignment group, this group can be viewed from the assignment group field on the incident form (We already have this set to only display specific groups that match 'types' set in the dictionary).
I am looking to implement the following: If someone is in the group (say Group 1) then check if this user is also in that group on submission of the incident, if not clear the field and display an error. If they are in the group on submission, keep populated and save incident.
How could I achieve this? Or if someone has done something similar, that'd be great!
Thanks,
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2024 06:01 AM
Hi @Wasdom_Kung, If you want to restrict the incident creation when the logged in user is not part of the assignment group, you can create a Before Insert Business Rule.
(function executeRule(current, previous /*null when async*/ ) {
if (!gs.getUser().isMemberOf(current.assignment_group)) {
gs.addErrorMessage("You are not an member of Assignemt group.");
current.setAbortAction(true);
}
})(current, previous);
Regards,
Sunil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2024 05:49 AM - edited 02-08-2024 05:49 AM
Good day,
It sounds like you want a Business Rule pointing at the incident table.
You want to check "advanced" and ensure the business rule runs "Before" the "Insert" and "Update" operations.
The code will look something like this...
(function executeRule(current, previous /*null when async*/) {
function checkGroupMembership(group, user) {
var gr = new GlideRecord("sys_user_grmember");
gr.addQuery("group", group);
gr.addQuery("user", user);
gr.query();
if (gr.hasNext()) {
return true;
} else {
return false;
}
}
if (checkGroupMembership(current.assignment_group, gs.getUserID()) == false) {
gs.addErrorMessage("Operation aborted - you are not a member of this assignment group");
current.setAbortAction(true);
}
})(current, previous);
If this helped you, please mark it as the solution, it really helps me!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2024 06:18 AM
Hi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2024 12:56 AM
It doesn't look like this specifies a group - I don't want it to run for every group, just a specific one.
So group 1 should only be able to be assigned to by people in group 1, however group 2-infinity can be assigned to by anyone, if that makes sense.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2024 01:29 AM
Good day,
You could add "assignment group = <the one(s) you want>" to the condition on the Business Rule!