how to get the sysid for a user using the username ex. like i have deepak.rawat and i want to pull the sysid of this

deepak rawat1
ServiceNow Employee

how to get the sysid for a user using the username ex. like i have deepak.rawat and i want to pull the sysid of this .

if there a way to pull the information for the sysid of a assignment group as well ? i trying to create incident with rest where i sending the username and assignment gourp , now incident is getting created but call and assigment group is not getting populated. i guess that is because i need to find the sysid of both for population so i need to find the sysid of both

10 REPLIES 10

thanks ankur i was able to use one of you old response in the community and that worked . i used querying the table . thanks you are amazing .

@deepak rawat 

Glad to know that it worked.

Please mark response as correct and helpful to close the thread.

Regards
Ankur

and how can we do reverse of it? i.e. we have user's sys_id and we need userid.

Willem
Tera Sage

To get the user you can use GET Call:

https://[your instance].service-now.com/api/now/table/sys_user?sysparm_query=user_name%3D[your username]&sysparm_fields=sys_id&sysparm_limit=1

https://stackoverflow.com/questions/56898872/get-the-user-sys-id-using-rest-api-in-servicenow

 

Group can be done similarly:

https://[your instance].service-now.com/api/now/table/sys_user_group?sysparm_query=name%3D[your group name]&sysparm_fields=sys_id&sysparm_limit=1

Hitoshi Ozawa
Giga Sage

Instead of using the OOTB REST API and doing multiple REST calls, it may be better to create a Scripted REST API to enable to do with just one POST call.

https://docs.servicenow.com/bundle/geneva-servicenow-platform/page/integrate/custom_web_services/con...