how to remove priority and impact choice list if user is not part of a group

Carol2
Tera Contributor

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

8 REPLIES 8

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');

 

Carol2_0-1732542326702.pngCarol2_1-1732542378701.png

 

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'); 
	}
}

 

 

 

Tejas1018
Tera Contributor

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');
    }