We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

get list of groups user belongs to

gtk
Mega Sage

we have created a new custom table with name u_work_group

in which it is having list of 50+ groups, and now we got a requirement that

create a field which refers to sys_user table

and when user is selected then ln a text box to be shown with list of groups that user is member of

agent - type is reference - points to sys_user

groups - type is text box - get group of user

(groups to be separated with comma [,])

16 REPLIES 16

ark6
Mega Guru

Try using gs.getUser().getMyGroups to get all the groups the logged in user belongs to..


this give me sys id how convert to name 

i tried getDisplayValue() and Value but not works

Gopu1
Giga Contributor

Where we need to write this script? 

Business rules?? 

gs.getUser().getMyGroups();