Can I use gs.getUser().getMyGroups()? I don't see getMyGroups() being suggested automatically when I write code

Kannan Nadar
Tera Guru

Hi All,

When I write any code using the code editor of ServiceNow, I do not see the function getMyGroups() being suggested automatically after I type in gs.getUser(). does this mean that ServiceNow does not suggests us to use that method? I can still see that it is working for now.

Thanks,
Kannan

1 ACCEPTED SOLUTION

Alberto Consonn
ServiceNow Employee
ServiceNow Employee

Hi,

if a fucntion is not showing in the code suggestion, it does NOT means that this function cannot be used in the Javascript Code, you just need to be sure that you're using it in a server side script and NOT in a client side script.

Hope this will clarify your doubt.

If I have answered your question, please mark my response as correct and/or helpful so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.

Thank you

Cheers
Alberto

View solution in original post

3 REPLIES 3

Anurag Tripathi
Mega Patron
Mega Patron

Hi Kannan,

You can use this method anywhere on the serverside code. It returns the array of sys_id , of groups, logged in user is member of.

 

-Anurag

-Anurag

Alberto Consonn
ServiceNow Employee
ServiceNow Employee

Hi,

if a fucntion is not showing in the code suggestion, it does NOT means that this function cannot be used in the Javascript Code, you just need to be sure that you're using it in a server side script and NOT in a client side script.

Hope this will clarify your doubt.

If I have answered your question, please mark my response as correct and/or helpful so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.

Thank you

Cheers
Alberto

Harsh Vardhan
Giga Patron

Agreed with @Anurag.

just want to add here. 

gs.getUser().getMyGroups() : It will return you the array list of groups, where current logged in user will be member of those groups.