Get User ID of caller while retriving incidents using REST Explorer

Michael51
Tera Guru

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 

 

@Ankur Bawiskar  @Maik Skoddow 

6 REPLIES 6

AnveshKumar M
Tera Sage
Tera Sage

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! 

 

Thanks,
Anvesh

Ankur Bawiskar
Tera Patron
Tera Patron

@Michael51 

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.

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

@Ankur Bawiskar  can I have sample reference code for this?

@Michael51 

you will find numerous examples in community for the same. I don't have script handy but it should be an easy one

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