Assigned to based on Assignment group and Vice Versa

aks4
Tera Contributor

So this customer has a requirement where they want to restrict Assignment group based on Assigned to Selection and Assigned to based on Assignment groups.

For example if a user is a member of 5 groups, then when his name is selected in Assigned to field, then those 5 groups should only be visible in Assignment Group field 

Similarly, if I select an Assignment group field then only members of that assigned to group should be visible in Assigned to fields.

Both of these use cases should exist in the system together.

Any thoughts on this requirement? 

9 REPLIES 9

@aks 

I have shared the logic.

Please enhance it further from your side.

Your original question was to filter both the fields with dependency on each other which I already answered.

Please mark my response as correct and close the thread.

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi @Ankur Bawiskar, I was able to apply this script and also i added the query for the filtered condition to look like this 

javascript: 'sys_idIN' + new global.ArrayUtil().convertArray(gs.getUser().getUserByID(current.assigned_to.toString()).getMyGroups()) + '^typeLIKE1cb8ab9bff500200158bffffffffff62';

This works fine but when i try to do a reversal, searching with assignment group, it comes back as empty. Can you advise on what to do please ?

melvinejiogu
Tera Contributor

Hi @Ankur Bawiskar, I was able to apply this script and also i added the query for the filtered condition to look like this 

javascript: 'sys_idIN' + new global.ArrayUtil().convertArray(gs.getUser().getUserByID(current.assigned_to.toString()).getMyGroups()) + '^typeLIKE1cb8ab9bff500200158bffffffffff62';

This works fine but when i try to do a reversal, searching with assignment group, it comes back as empty. Can you advise on what to do please ?

i tried ankur's solution and got the same results you did.  i ended up using a script include to achieve the functionality I think you want.   just call the script include from the assignment group ref qualifier field.  you can include your other filters in that ref qualifier field.  something like...javascript:'type=null^nameNOT LIKESystem Administration^' + u_backfillAssignmentGroup();

this should give you what you want...https://www.servicenow.com/community/developer-forum/assignment-group-not-auto-populating-when-tree-...

Jean-Yves1
Tera Expert

Hi,
Based on Ankur Bawiskar proposal, I adapted it and seem to work:

javascript: if(current.assigned_to.toString() == '') {'active=true^typeLIKE1cb8ab9bff500200158bffffffffff62'} else {'active=true^typeLIKE1cb8ab9bff500200158bffffffffff62^sys_idIN' + new global.ArrayUtil().convertArray(gs.getUser().getUserByID(current.assigned_to.toString()).getMyGroups());}

 

Please take attention that the type is ITIL. So you must check the reference qualifier override to ensure that it is applied/or not where you need.
I hope it's help.

JY