Populate a field by DOT-WALK via REST

mballinger
Mega Guru

Hello,

We have a requirement to create an incident record on another ServiceNow instance and populate the Caller using a user_id via REST Integration. We are using the user_id because the sys_id's in both instances do not match up. Also, we cannot send over the name because there could be multiples. The user_id is a unique identifier, but I am having issues sending in the script. Currently, we are able to create the Incident Record with our current payload but dot-walking seems to be an issue.

 

The REST is currently triggered via a Business Rule. When the Business Rule is triggered, a call is made to a script include where the execution of the REST occurs. When I try to dot-walk it breaks and the Incident record in the other instance is not created.

 

This is what I have:

createIncident: function(current) {
   var user_id = current.u_submitter.user_id;
   var description = current.u_description;
   var state = current.u_state;

   var result = this.sendRequest(user_id, description, state);
}

sendRequest: function(user_id, description, state) {
   try {
      var r = new sn_ws.RESTMessageV2('createIncident', 'Create/Update');
      var json = {};

      json.caller_id.u_user_id = user_id;
      json.description = description;
      json.state = state;
      
      var strJSON = JSON.stringify(json);

      r.setRequestBody(strJSON);
      var response = r.execute();
      var responseBody = response.getBody();
      var httpStatus = response.getStatusCode();  
    
   } catch(ex) {
      var message = ex.message;
      gs.error("Error in Incident Creation " + message, "Incident Integration");
   }
 
}

 

Again the only piece that is not working is the population of the caller_id when using the dot-walk. Variables and definitions are all working fine. I am not an admin on that side so troubleshooting is a little difficult.

 

Anything helps!

 

Thanks!

1 ACCEPTED SOLUTION

Yes, that would be how I would configure.

View solution in original post

5 REPLIES 5

Thanks for your response! The BR is running on my instance as well as the REST. u_submitter, u_description, and u_state are all custom fields on our custom table. The values all correlate to the ITSM instance. u_user_id is a custom field on the user table in both instances that map to the same user on both platforms. The incident form on the ITSM instance uses the OOB caller_id field and not the u_user_id field. The only way to map callers on both instances is to use the u_user_id, but I’ve been unsuccessful in doing so. The dot-walk method does not seem to be working caller_id.u_user_id.