eBonding spoke action Error: Cannot read property "sys_id" from undefined,Detail: Cannot read property "sys_id" from undefined


Description

eBonding spoke "Update Remote Incident" action failing with Error: Cannot read property "sys_id" from undefined, Detail: Cannot read property "sys_id" from undefined.

Resolution

eBonding spoke comes with the below actions.

All the above actions use correlation_id as a primary query parameter, in problematic scenarios this API never returns any response. The response body is always empty even if we execute this API from the rest of the API explorer.

eBoding uses the below API to perform Get/Update/Create actions.

GET https://instance.service-now.com/api/now/table/incident?sysparm_limit=1&correlation_id=INC0128611.  

In the problematic scenario we are receiving below response which doesn't have any data.

Returning :

{
"result": []
}

Since the response body is empty and OOB action "Update Remote Incident" is expecting a valid sys_id in response, so the flow is getting failed with the exception.


2021-03-08 01:32:06 (144) Default-thread-11 EF5F4E891BB2E0107552FF7E034BCB25 txid=0b835ac51b72 WARNING *** WARNING *** Evaluator: org.mozilla.javascript.EcmaError: Cannot read property "sys_id" from undefined
Caused by error in Process Automation.06a649b0b3f0030024a3051a16a8dc02 at line 9

6: throw "Error retrieving incident. Message: "+errorMsg + " Details:"+errorDetail;
7: } else {
8: var result = responseBody.result[0];
==> 9: outputs.incident_sys_id = result.sys_id;
10: }
11: })(inputs, outputs);

Below is the script snippet which is expecting a valid sys_id in response.

(function execute(inputs, outputs) {
var responseBody = JSON.parse(inputs.response);
if(inputs.status!=200){
var errorMsg = responseBody.error.message;
var errorDetail = responseBody.error.detail;
throw "Error retrieving incident. Message: "+errorMsg + " Details:"+errorDetail;
} else {
var result = responseBody.result[0];
outputs.incident_sys_id = result.sys_id;
}
})(inputs, outputs);



Correlation id is a mapping parameter for incidents in 2 different systems. In the target system, you are expecting an incident with Cor-ID as "INC0128611" in the target which resulted in an error. that means no incident exists in the target system.

Before performing update action, the incident record should be created using create action so that the correlation_ID will be populated in the source and target instance. If the correlation_id is empty in the target instance then we will see this exception "sys_id" from undefined, Detail: Cannot read property "sys_id" from undefined."

create one incident record using " "Create Remote Incident action" " and then try to update the remote record using "Update Remote Incident action" .