ServiceOder Open API throw error while using external ID

Mythili Searn
Kilo Contributor

I am using Service Order Open API to create service order. I am using the example payload given in servicenow document. I have just removed the sys_id and updated them with external ID. External ID for Service Specification, Place, Account and Contact. But I get error for Account and Place. After providing sys_id for these 2, order is getting created. Only service specification and Contact is getting mapped with external id. 

How to override the Account and Place validation/mapping? Anybody done custom fields for mapping additional parameters, which are not in the example?

Below is error message I get while using external ID. 

{
  "code": 23,
  "reason": "Missing body field",
  "message": "Missing body field",
  "details": [
    {
      "message": "Invalid payload: Customer Account does not exist",
      "datapath": "/relatedParty[1]/"
    },
    {
      "message": "Invalid payload: The place doesn't exist in the system",
      "location": "serviceOrderItem[0]:200south"
    }
  ]
}
1 ACCEPTED SOLUTION

Shubham44
ServiceNow Employee
ServiceNow Employee

Please let me know if you have any more queries else please mark the response helpful and correct

View solution in original post

10 REPLIES 10

Shubham44
ServiceNow Employee
ServiceNow Employee

hi Mythili,

The same external Id needs to be updated in the Servicenow customer_account and Servicenow cmn_location table for the API validation point of view.

 

Please mark the response helpful and correct if appropriate.

Yes Mittal, External ID is mapped in account and Place. It is also mapped for service specification and contact. Issue mapped IDs working for Service specification and contact, not for account and place.

 

find_real_file.png

find_real_file.png

hi Mythili,

Can you please confirm that which version of OMT are you using?

Have you upgrade to San Diego and if yes then 

a) For Account

check the TMFOrderAPIConstants and see that in the ProductOrderSchema, there is an escaped JSON schema attached(you can unescape it using online tools) you should be able to see the exernal id also the field validation

"reference": [
{
"referenceKey": "id",
"table": "customer_account",
"field": [
"sys_id",
"sn_ind_tsm_core_external_id"
],
"errorMsg": "Invalid payload: Customer Account does not exist",
"referenceCondition": {
"conditionKey": "@referredType",
"conditionValue": "Customer",
"conditionOperator": "=="
}
}

 

b) Similarly for location in TMFProductOrderAPIUtil you should be able to see the below

  var locationRecord = this.apiCoreUtil.getRecordBySysIdOrAlternateId(orderLineItem[i].product.place.id, Constants.TABLE_LOCATION, sn_ind_tsm_core.Constants.TSM_EXTERNAL_ID);

 

If you don't see this then either you upgrade to San Diego or raise a Hi ticket so that our technical team can then do it on your instance.

 

Please mark the response correct and helpful.

I am using San Diego version. OMT version 2.00

find_real_file.pngI am able to see both the above code in the script. 

I had mapped external ID(sn_ind_tmt_orm_external_id).

After updating values in external ID(sn_ind_tsm_core_external_id) for account and location, Order is getting created. 

It is creating confusion between sn_ind_tmt_orm_external_id and sn_ind_tsm_core_external_id. 

For service specification, external id is sn_ind_tsm_orm_external_id.

Can you provide more details on these two fields? or link to get more details about these fields.?