The CreatorCon Call for Content is officially open! Get started here.

CMDB Instance REST API and Reference fields when creating records from external system

Yopisn
Tera Contributor

Hello,

I have an external system posting data to our ServiceNow instance through the CMDB Instance REST API.

The issue is with Reference fields: I cannot find a way to send the name or display name of a reference field through a POST and have ServiceNow get the proper record in the table referenced to reference it in the CI.

E.g.: the external system is sending a manufacturer along with each CI. The manufacturer is sent in the request body with it's name and not sys_id (manufacturer:XYZ). When API is called, ServiceNow use the name as a sys_id so it doesn't match a record and the manufacturer is empty when the CI created (manufacturer field reference the core_company table), even though a company exists with the name XYZ.

I tried different things to fix that but cannot solve. Note that the external system cannot request the related record sys_id first through another API call.

Thanks for your help!

 

7 REPLIES 7

Chuck Tomasi
Tera Patron

Have you taken a look at sysparm_display_value? I've used it on outbound REST requests, but haven't tried it with inserting in to tables. Try setting it as sysparm_display_value=true.

 

sysparm_display_valueData retrieval operation when grouping by reference or choice fields. Based on this value, the query returns either the display value, the actual value in the database, or both.
  • true returns display values for all fields.
  • false returns actual values from the database. If a value is not specified, this parameter defaults to false.
  • all returns both actual and display values.
There is no preferred method for setting this parameter. However, specifying the display value may cause performance issues as they are not read from the database and may reference other fields and records. For more information on display values and actual values, see Table API FAQs (KB0534905).

Hi Chuck, thanks for your reply. I did try this one but it didn't help (just tested again with REST API Explorer).

I also tried sysparm_input_display_value=true query parameter but it seems like this parameter is only for the table API and not the CMDB instance API.

Sorry about that. I thought you were using the table API and was unaware of the CMDB Instance API until now. Good to know. Sorry there's no sysparm_display_value thingy for CMDB Instance API.

Patrick DeCarl1
ServiceNow Employee
ServiceNow Employee

Are you using the CMDB API so you data goes through the IRE (Identification and Reconciliation Engine)?

You might need to make a second call to get those sys_ids for company data.