Get User ID of caller while retriving incidents using REST Explorer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2023 09:48 PM
Hi All ,
External System is using GET method to get Incidents , changes and Problem from ServiceNow using Task Table , everything Works good , but here the latest requirement was to Show "Created by with user ID" instead user name
Example : Abel tutor it should show ABEL
I have tried to extend field from reference and tried to add in the table but it is not working
can anyone help me how to get access to user fields in rest api explorer to dot walk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2023 10:27 PM
Hi @Michael51 ,
You can pass the dot walked fields in sysparm_fields of the URL to get those values, for example I want to get the User ID of caller, Incident number, Short Description the URL would be like this,
https://<Instance_Name>.service-now.com/api/now/table/incident/sysparm_fields=caller_id.user_name%2Cnumber%2Cshort_description
And the result will be like this.
{
"result": [
{
"caller_id.user_name": "employee",
"number": "INC0000060",
"short_description": "Unable to connect to email"
}
]
}
Try this way!
Anvesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2023 10:39 PM
created by is string and holds user-name. so you cannot use that field to dot walk.
they need to make another API call and hit sys_user with that username and get the name of the user
OR
you need to use scripted rest api and send custom response as per what they require
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2023 11:09 PM
@Ankur Bawiskar can I have sample reference code for this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2023 11:24 PM
you will find numerous examples in community for the same. I don't have script handy but it should be an easy one
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader