how to remove priority and impact choice list if user is not part of a group
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2024 02:16 AM
Hi
I have a user requirement here to hide p1 and p2 incidents if a user is not part of the major incident group. Not everyone should submit a p1 and p2.
How do i go about resolving this?
Regards
Ca
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2024 05:40 AM
Hi @Carol2 ,
Did you changed the group name App Engine admin to major incident group.
Attach the screenshots with script you have written.
Mark it as helpful and solution proposed if it serves your purpose.
Thanks,
Anand
g_scratchpad.grp = gs.getUser().isMemberOf('App Engine Admins');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2024 05:46 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2024 05:53 AM
Hi @Carol2 ,
It should be remove option not add option
function onLoad() {
var usr = g_user.getUserID();
if (!g_scratchpad.grp) {
g_form.removeOption("impact", '1');
g_form.removeOption("urgency", '1');
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2024 05:54 AM
Hi,
You can write an onLoad client script to check if the user is part of a specific group. If they are, you can remove all existing options from the Priority field and add the custom option. try with following code.
var userGroups = gUser.getMyGroups();
var isMajorIncidentUser = userGroups.indexOf('major_incident_group') !== -1; // Replace 'major_incident_group' with the actual group Sys ID or name
// Clear all options from the Priority field
gForm.clearOptions('priority');
if (isMajorIncidentUser) {
// If the user is part of the Major Incident Group, add all priority options
gForm.addOption('priority', '1', 'P1 - Critical');
gForm.addOption('priority', '2', 'P2 - High');
gForm.addOption('priority', '3', 'P3 - Moderate');
gForm.addOption('priority', '4', 'P4 - Low');
} else {
// If the user is not part of the Major Incident Group, add only allowed options
gForm.addOption('priority', '3', 'P3 - Moderate');
gForm.addOption('priority', '4', 'P4 - Low');
}