Get Sys_ID of Reference Field when POST

TramaineM
Kilo Sage

Hello, I have probably a noob scripting question.

We are testing one of our external systems to create records (Interactions) in ServiceNow. This is working fine however one of the fields that we are trying to push to is a Reference Field (contact). The problem is our external system won't have the name of the person but instead has an ID that would also be on the contact's record. 

Since the external system won't have the user's Sys_ID of ServiceNow, how would we pass that unique ID (u_seq_id) to ServiceNow for it to know which name to populate in the Contact field?

Here is a POST sample code:

{
"short_description":"Testing",
"work_notes":"Let's test this",
"assignment_group":"9594fg9rg4g9r9g59g44sd954845f5rfr",
"account":"965985695",
"contact":{
             "link": "HTTP://companyname.service-now.com/api/now/table/customer_contact? 
                  u_seq_id=665555",
             "value":"sys_id"},
"state":"new"

}
5 REPLIES 5

Giles Lewis
Giga Guru

Hi Tramaine.

There are three possible solutions.

Option One: The external system makes two REST calls

  1. GET sys_user to determine the sys_id of the contact
  2. POST interaction to insert the interaction

Option Two: Create a Web Services Import Set

Option Three: Create a Scripted REST API.

 

Option One means that you do not do any custom work in your ServiceNow instance. The burden is shifted to the team supporting the external integration. Option One is also the least efficient because it requires two REST calls whereas all the other solutions require only a single REST call.

Option Two is good if you are already familiar with Transform Maps. I agree with Drew that this is the best option since it is a simple no-code solution. However, you need to remember that all the input variables of your new API will begin with "u_".

Option Three was recommended by Hitoshi. This option ultimately gives you the most flexibility in designing a new API which works any way that you want. However, it does require you to write some JavaScript code.