How to define the Caller for incident record

patricktownsend
Kilo Explorer

Hello,

I am using the REST interface to create an incident record. This is working fine except that the Caller field is blank in the new incident. The REST interface does not seem to have a field for "caller", but I do see that there is a field for "caller_id". However, I can't seem to find the caller_id value on a user record. Any pointers would be appreciated.

Patrick

1 ACCEPTED SOLUTION

Sort-of.   That goes back to what I was saying above - it's a reference field, and SHOWS you the Display value of the sys_id supplied.   If the Display Value is distinct, the system should be able to turn that into the sys_id you need, and will work fine, but if you ever end up with more than one "John Smith" in your organization, you're not likely to end up with the right value.



If you look at the incident form as admin, right click and Show XML, it'll show you both the Display Value (string name) and the sys_id, but the true value of the field is the sys_id.


View solution in original post

11 REPLIES 11

Awesome!   I would have suggested the show xml first, but when you mentioned you were working with someone on the ServiceNow side, I figured you may not have access to see that.



One other thing it's great for is that, in show XML, it tells you the real field name (rather than the label).   Since it doesn't show both, you may have to guess a bit, but you can also confirm it by right clicking on the field you want.



One of the things I really like about ServiceNow is that every table is REST enabled by default, even brand new ones as they're created, so you can use the same REST queries above to pick any table in the system, as long as you know the field names and table names (and have access).


That's a very valid point.


In case it helps someone else, this is how I send the caller_id via http as JSON body:



var urlString = 'https://xxxxxx.service-now.com/api/now/table/incident?sysparm_input_display_value=true';


var data = {


    "caller_id": "javascript:gs.getUser().getFullName()",


}



Of course this will only work if the user you want to have as Caller is the one that is currently logged in. But it will take the right user if you have more than one with the same name.