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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2020 01:33 AM
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
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2020 08:43 AM
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 .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2020 08:49 AM
Glad to know that it worked.
Please mark response as correct and helpful to close the thread.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2021 01:31 PM
and how can we do reverse of it? i.e. we have user's sys_id and we need userid.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2020 01:45 AM
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

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2020 04:04 AM
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.