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

Anand Kumar P
Giga Patron
Giga Patron

Hi @Carol2 ,

 

Create script include and check if user is part of major incident group return true or false form script include to client script. In client script hide choices for impact and urgency.

 

Refer below link for more info:

https://www.servicenow.com/community/developer-forum/hide-choice-on-incident-form-for-some-users/td-...

Mark it as helpful and solution proposed if it serves your purpose.
Thanks,
Anand

 

Carol2
Tera Contributor

@Anand Kumar P I followed the link provided but something doesn't work. the script doesn't hide the priority 1 for example if user doesn't belong to the group. what am i missing?

 

Carol2_0-1732532383507.png

 

script include

 

Carol2_1-1732532470800.png

 

 

 

 

Hi @Carol2 ,

You are missing lot of things in client script and script include leave client script and script include.

 

Create one new display business rule and paste below code

 

 

(function executeRule(current, previous /*null when async*/) {
g_scratchpad.grp = gs.getUser().isMemberOf('App Engine Admins');  change group name form App Engine Admins to your Major incident group name
})(current, previous);

 

 

Create onload client script in incident table and paste below code

 

 

function onLoad() {
   var usr = g_user.getUserID();
   
    if (!g_scratchpad.grp) {
      
        g_form.removeOption("impact", '1'); 
        g_form.removeOption("urgency", '1'); 
	}
}

 

 

I tried in my PDI working as expected. All code which i pasted is same just you have to replace with your group name in display BR.

 

Mark it as helpful and solution proposed if it serves your purpose.
Thanks,
Anand

@Anand Kumar P Hi, 

 

This is helpful but this removes the impact and urgency 1 for everyone.