getMyGroups() function is returning any parent group of child group in bread crumb

yashu1995
Kilo Guru

getMyGroups() function is returning any parent group of child group in bread crumb

is it expected?

1 ACCEPTED SOLUTION

andy_ojha
ServiceNow Employee
ServiceNow Employee

Hello - yes, as you've noted this is the baseline / default behavior of the 'getMyGroups()' function, as with using the the "is(dynamic) One of my groups" filter condition.

You can find additional details referenced in KB0681349.

---------------------------------------------

KB: https://hi.service-now.com/kb_view.do?sysparm_article=KB0681349 

User is able to see a list of records from the groups that user is a part of and also the groups which are parent to the group.

Cause:

This is an expected behavior. It happens when the filter condition is(dynamic) - One of my groups returns all the groups of the user and also the parent groups associated with these groups.

The dynamic filter is returning all the groups that a user is part of and also the parents of these groups. 

Solution:

  • One way to achieve the solution could be to write a custom function that returns only the groups(child) that a user is part of.
  • This function can then be used in the 'Script' field of One of my groups dynamic filter definition.
  • While writing the custom script you can make use of the 'sys_user_grmember' table which has relationship between a user and all the active groups he is part of.
  • Please use the below articles for reference:
  • Changing or Creating a new getMyGroups() function
  • Advanced 'getMyGroups' function  ( NOTE: The scripts are examples to achieve the custom requirements. The examples shown in community links are not owned or tested by ServiceNow)

View solution in original post

6 REPLIES 6

yashu1995
Kilo Guru

User is member of child group

SaiRaviKiran Ak
Giga Guru

The ‘getMyGroups’ function simply returns an array of group sys_id values for the groups that a user belongs to

mike_allgire
Giga Guru

What are you attempting to do and can you give a sample of the script?

 

https://docs.servicenow.com/bundle/jakarta-application-development/page/app-store/dev_portal/API_reference/GlideUser_global/concept/GUserAPI.html#GUser-getMyGroups

Hi mike,

We have a dynamic filter "one of my groups" for a module "un-assigned".

inside the dynamic filter "getMyGroups()" is getting called from business rule "groups, banners" oob one.

When i open the parent group "xxx" which is present in breadcrumb, There is no user present to that group.

User is part of "yyy" child group. The child group has parent "xxx".

In the breadcrumb filter "yyy" group is also present.

Since this is oob code just wanted to check if "getMyGroups()" returns parent group as well