How to get only the 'Groups' of a 'Requested For' user (Service Catalog)

pjftenorio
Tera Expert

Hi, I'm trying to display only the Groups of the Requested User Field in my Service Catalog.

Upon using script - "javascript:'user='+current.variables.requested_for;" it only displays sys_id of Groups how to I display the display value of the Groups?

 

Service Catalog Form: 

pjftenorio_0-1694669935617.png

 

Variable declaration:

pjftenorio_1-1694669947629.png

 

 

2 ACCEPTED SOLUTIONS

@pjftenorio 

there was a type in my above response; it should be IN and not NIN

update as this

javascript: 'sys_idIN' + new global.ArrayUtil().convertArray(gs.getUser().getUserByID(current.variables.requested_for).getMyGroups());

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

RAMANA MURTHY G
Mega Sage
Mega Sage

Hello @pjftenorio ,

 

Please try below

RAMANAMURTHYG_0-1694676159183.png

your table should be reference to sys_user_group table not sys_user_grmember

and write Advanced reference qualifier as below

javascript&colon; 'sys_idIN' + new global.ArrayUtil().convertArray(gs.getUser().getUserByID(current.variables.<requested_for_field_name>).getMyGroups());

// replace requested for back end name at <requested_for_field_name> 

 

Please mark my answer as Helpful, if it is correct and help you.

Thank you

Please mark my answer helpful  & correct if it helps you
Thank you

G Ramana Murthy
ServiceNow Developer

View solution in original post

6 REPLIES 6

Venkatesh_N
Tera Guru

Hi @pjftenorio ,
To Display the group's name instead of SysID, In the Pop up view of groups iteself, Go to Configure --> List Layout and Select the User Field to the Right side. Refer below image:

Venkatesh_N_0-1694674398525.png

 

I hope this helps. Mark my answer correct & Like Helpful, if Applicable.

Thanks!
Venkatesh Nekkanti

RAMANA MURTHY G
Mega Sage
Mega Sage

Hello @pjftenorio ,

 

Please try below

RAMANAMURTHYG_0-1694676159183.png

your table should be reference to sys_user_group table not sys_user_grmember

and write Advanced reference qualifier as below

javascript&colon; 'sys_idIN' + new global.ArrayUtil().convertArray(gs.getUser().getUserByID(current.variables.<requested_for_field_name>).getMyGroups());

// replace requested for back end name at <requested_for_field_name> 

 

Please mark my answer as Helpful, if it is correct and help you.

Thank you

Please mark my answer helpful  & correct if it helps you
Thank you

G Ramana Murthy
ServiceNow Developer