Need to check login user is member of Analytics, Managers (assignment group).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2024 04:58 AM
Hello everyone,
I need to ensure that a ticket can only be submitted if the logged-in user is a member of any one of the following groups: Analytics, Managers, App Engine Admins, or App Engine Studio. For example, if the user selects an assignment group as Change Management, logged-in must be a member of Change Management and above mentioned groups. If the user does not belong to any of these groups and the selected assignment group, they should not be able to submit the ticket. A warning message should be displayed to the user before submission to indicate this restriction. Please help me to solve this work. This is high priority task. Thank you.
Best Regards,
Praveen Rajan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2024 05:15 AM
Hi @praveen1231 try Before Insert/Update BR
(function executeRule(current, previous /*null when async*/) {
var allowedGroups = ['Analytics', 'Managers', 'App Engine Admins', 'App Engine Studio'];
var user = gs.getUser();
var userGroups = user.getMyGroups();
var isUserInAllowedGroup = false;
for (var i = 0; i < userGroups.length; i++) {
if (allowedGroups.indexOf(userGroups[i].name) !== -1) {
isUserInAllowedGroup = true;
break;
}
}
var selectedGroup = current.assignment_group.getDisplayValue();
if (isUserInAllowedGroup || userGroups.indexOf(selectedGroup) !== -1) {
return;
}
gs.addErrorMessage('You must be a member of one of the following groups to submit this ticket: Analytics, Managers, App Engine Admins, or App Engine Studio, and the selected assignment group.');
current.setAbortAction(true);
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2024 05:28 AM
Hi @Sid_Takali Thanks for your valuable timing. But it not working as we expected.
In the provided image, the logged-in user is identified as a system administrator, and the assignment group selected is "App Engine Admins." Despite this, an error is being reported stating that the system administrator does not belong to the "App Engine Admins" group.
I’ve already added the System Admin as a member of the "App Engine Admins" group. Could you please verify why the script is not recognizing this group membership?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2024 05:35 AM
Hi @praveen1231 In the array add the sys_id of the group
var allowedGroups = ['Analytics', 'Managers', 'App Engine Admins', 'App Engine Studio'];
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-07-2024 05:44 AM
Hi @Sid_Takali Facing same error again.