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

Need Group Name instead of Sys Id in JSON query

SN Rookie
Giga Expert

Hi All,

I'm fetching a simple API query which is returning the group details of specific user. However, the group name is being returned as a sys_id instead of display name. How can I achieve that?

My REST Query is as below - 

https://<instancename>.service-now.com/api/now/table/sys_user_grmember?sysparm_query=group.typeLIKE7bba903b0a0aa01e007536d6d0711429%5Egroup.active%3Dtrue&user.user_name=a376625

 

1 ACCEPTED SOLUTION

Sanbir Singh1
Kilo Guru

Just add the below line of code in the API and it should work fine - 

 

&sysparm_fields=group.name

View solution in original post

9 REPLIES 9

SN Rookie
Giga Expert

My Output looks like below - 

 

"result": [
{
"sys_id": "1ec1b7c2c50ca4000ca9f83670b4cda6",
"sys_updated_by": "A384085",
"sys_created_on": "2012-02-09 15:03:16",
"sys_mod_count": "0",
"sys_updated_on": "2012-02-09 15:03:16",
"sys_tags": "",
"user": {
"link": "https://fildev.service-now.com/api/now/table/sys_user/0108188f0a0aa02e010ed579ba132de1",
"value": "0108188f0a0aa02e010ed579ba132de1"
},
"sys_created_by": "A384085",
"group": {
"link": "https://fildev.service-now.com/api/now/table/sys_user_group/f3bf638ec5c8a4000ca9f83670b4cdd2",
"value": "f3bf638ec5c8a4000ca9f83670b4cdd2"
}
},
{
"sys_id": "f7f7ec9d0a0aa02d00f78bed203fd765",
"sys_updated_by": "russell.hart@innovise.com",
"sys_created_on": "2011-05-16 08:41:51",
"sys_mod_count": "0",
"sys_updated_on": "2011-05-16 08:41:51",
"sys_tags": "",
"user": {
"link": "https://fildev.service-now.com/api/now/table/sys_user/0108188f0a0aa02e010ed579ba132de1",
"value": "0108188f0a0aa02e010ed579ba132de1"
},
"sys_created_by": "russell.hart@innovise.com",
"group": {
"link": "https://fildev.service-now.com/api/now/table/sys_user_group/070a232f0a0aa02e012d4f6a38ed4257",
"value": "070a232f0a0aa02e012d4f6a38ed4257"
}
}
]

 

This should show the group name and not the sys id (highlighted in bold)

Omkar Mone
Mega Sage

Hi 

Can you help me with the code for the same?

I haven't written any code Omkar. Just ran the below query in Postman and it returned sys_ids. 

 

https://<instancename>.service-now.com/api/now/table/sys_user_grmember?sysparm_query=group.typeLIKE7bba903b0a0aa01e007536d6d0711429%5Egroup.active%3Dtrue&user.user_name=a376625

Hi 

Yes because these two are reference fields on the "sys_user_grmember" table. That is why it is returning the sys_id in the url for the same.