Update fields inside a reference field with rest API (Similar to updatewithreferences() command).

avid
Kilo Expert

Hello.

I need to update fields within a reference record by rest API (Similar to updatewithreferences() command ).

I tried to send this body by rest API update to the incident table but with no success:

{"assigned_to.email":"example@gmail.com"}

Any suggestion?

6 REPLIES 6

Rogers Cadenhe1
Giga Guru

Are you calling ServiceNow's table API?

Yes. A rest call via rest api explorer, and editing the JSON with the raw tab .

Rogers Cadenhe1
Giga Guru

Here's an old discussion where someone was trying to set location.latitude and location.longitude in a table API PUT call:

TABLE API write options

At the end they state "this is not currently possible with the Table API."

If that is still the case, you could create your own inbound REST API call and set as many table records as needed with GlideRecord queries.

Yes, That what I did. the problem is that I only get the fields name and value and not the table. 

Unfortunately, dot walking does not work with setValue() , for example gr.setValue ('assigned_to.email', 'my@email.com') doesn't work even if you call updatewithreferences() in the end. 

To bypass that problem, I created a string that contains the script syntax, for example, it's generating these commands: gr.assigned_to.email= 'my@email.com'; and gr.updatewithreferences() and run it with evaluate script command.