Need help with script to make it so that two groups can't be seen on the pick list for everybody except those two groups.

Lee Kraus2
Tera Guru

So here is an example I found and slightly massaged already:

 

if(!gs.getUser().isnotMemberOf('sys_id')){ //sys_id of group to check if user is a member of
    current.addQuery('sys_id','!=','sys_id_of_group_to_hide');
}

 

(In that example, I changed !gs.getUser().isMemberOf('sys_id') to .isnotMemberof and it seems to work as an option)

 

I'm editing the script under Business Rules > group query that uses the Group [sys_user_group] table. I left the default JavaScript alone: if (!gs.hasRole("admin") && gs.getSession().isInteractive()) {current.addQuery("active", "true");} (edited here to be on one line). 

 

I'm trying to get two of our groups to not get tickets back assigned to them, essentially I need them to not show up on the Assignment Group dropdown of other groups. Currently if I use just this line of code and put in the sys_id of one of GroupA in the top argument, and put sys_id of GroupB in the spot of sys_id_of_group_to_hide that group becomes invisible to anyone except GroupA, including anyone in GroupB, so, not ideal. 

 

So what I'm asking for help here is how to I make it so that GroupA and GroupB see all the groups on the dropdown menu, but the other groups don't see GroupA or GroupB. I feel I'm close, but I don't have the coding experience to get this nailed down. 

 

All help is greatly appreciated!

1 ACCEPTED SOLUTION

Muhammad Khan
Mega Sage
Mega Sage

Hi Lee,

As per my understanding of your requirement, you can create an onDemand function using Script Include, and call it in the Override reference qualifier for assignment_group field of incident table.

For reference see the below images.

find_real_file.png

find_real_file.png

 

Hopefully, this will help you resolve your query.

View solution in original post

6 REPLIES 6

Ethan Davies
Mega Sage
Mega Sage

Hey Lee,

You should be able to achieve your goal of not showing Group A and Group B the Group field with the following steps:

TL;DR - You can limit the groups that are shown in your assignment field by leveraging the Type field on a group record.

Step 1:

find_real_file.png

 

Step 2:

find_real_file.png

Step 3:

find_real_file.png

Step 4:

find_real_file.png

Setting up Group A and Group B with or without a Type should allow you to hide them from the assignment, once you've set your Reference Qualifier on your group field.

P.S - I would not recommend editing/creating a Query Business Rule on the instance. These can be a huge pain to debug and understand why certain records are missing or not. The better alternative if you wanted to go down a similar route would be to use ACLs.

Let me know if you run into any issues.

Please mark my answer correct or helpful if it has helped solve you issue, thanks!

Lee Kraus2
Tera Guru

Well I'm already lost on Step 2 sadly. When I look into the dictionary config for Assignment group, my second option is what looks to be a sys_id of some sort, and when I click on the magnifying glass to look up other options, itil isn't one of them.

find_real_file.png

 

find_real_file.png

for Step 3, I clicked on the incident link since that's the type of ticket I'm trying to restrict visibility on, but I don't know what attributes I should add or what override options I need to make true. 

find_real_file.png

 

and for Step 4, sadly that seems tied to step 2 and I don't have the itil type in my list. I'm uncertain what would happen if I created a new group type called "itil" if that would affect anything. 

So while that might be what I couldn't figure from your example (which, thank you very much for replying and taking the time, I greatly appreciate it!), I did try to do some ACL work earlier and I wasn't getting what I needed either. 

 

I tried making a role to assign to the two groups but couldn't figure out how to make it so that rule allowed visibility to their own groups in Assignment Group while removing it from everyone else's dropdown menu. I'm sure I did something incorrect here as well since nothing seemed to happen when this ACL was on.

 

find_real_file.png

 

(I covered up the groups for company privacy concerns as well as the description)

 

These are all from trying to find examples in the Community here but I feel I'm not finding quite what I'm looking for a lot of the time when I'm sure the questions have been asked before me and recently. 

 

I apologize for my ignorance, I'm just trying to learn this stuff on the fly as I'm needing it while also trying to learn the basics for the ServiceNow Certified System Administrator certification. 

After further trying the steps above, I can get the groups I don't want to show removed from the dropdown, but now it's that way for all viewers. 

To explain how I got there:

I created a custom role and assigned it to the (now) 3 groups I need full Assignment Group visibility. 

I created a custom group type, went to the groups that will need to see all the list, gave them that "type" in their forms. 

Then I went back to the Assignment Group dictionary, and updated the Reference qual conditions to these:

find_real_file.png

so that if there is no type or if it's not the custom group type, it should show up. So far, so good. Now I'm trying to make it so that those Assignment groups show up for the 3 groups that need to see everything, so I go to the Dictionary Overrides section, and click on incident, since that's the ticket type I'm trying to alter. I put in the following:

find_real_file.png

From what I've read (and might not have read correctly after a couple times) is if I put in the role that should override the Reference Specification, then anyone/group with that role will see the whole list, and anyone/group without would just see the Assignment Group list minus the 3 I need hidden from them. What I get unfortunately is a full removal of visible groups in the Assignment Group dropdown for any user. 

 

Can you show me what I'm doing wrong here? 

Muhammad Khan
Mega Sage
Mega Sage

Hi Lee,

As per my understanding of your requirement, you can create an onDemand function using Script Include, and call it in the Override reference qualifier for assignment_group field of incident table.

For reference see the below images.

find_real_file.png

find_real_file.png

 

Hopefully, this will help you resolve your query.