How to modify default Web service import set response

rajeshraya
Giga Expert

Hi,

I created a SOAP web service import set to import records from third party tool.

After sending the payload of the record to be created in ServiceNow, 3rd party tool expects a customized XML response. I built this custom XML response with a business rule on my target table and which is working fine.

But the issue is that ServiceNow is sending a default XML response which has the SYS_ID of the import set record. This is overriding my custom response on the 3rd party tool side. 

My question(s):

Is it possible to restrict the OOB XML response? If not, How to modify that OOB XML response to send my custom fields in it.

Thanks

Rajesh

1 ACCEPTED SOLUTION

sachin_namjoshi
Kilo Patron
Kilo Patron

You can add this in your transform map scripts for adding custom messages in your response.

 

 

 

if(source.email == ""){

 

    response.custom_error = "Invalid email";

 

    ignore = true;

 

}

 

 

This will return back a new node in your response:   <custom_error>Invalid email</custom_error>

 

or you achieve this using scripted web service.

 

Regards,

Sachin

View solution in original post

4 REPLIES 4

sachin_namjoshi
Kilo Patron
Kilo Patron

You can add this in your transform map scripts for adding custom messages in your response.

 

 

 

if(source.email == ""){

 

    response.custom_error = "Invalid email";

 

    ignore = true;

 

}

 

 

This will return back a new node in your response:   <custom_error>Invalid email</custom_error>

 

or you achieve this using scripted web service.

 

Regards,

Sachin

rajeshraya
Giga Expert

Thank you very much Sachin!

Dhanik Ram Kha1
Tera Contributor

In this case, 

1. What does custom_error mean or where does it come from?

2. What does this do?

3. How to use response?    (responseDOT) do we use any field name? which field name? 

 

if(source.email == ""){

    response.custom_error = "Invalid email";  // what does custom_error mean or where does it come from

    ignore = true;  //what does this do?

 

}

custom_error is one of the JSON variable of response paylaod which is created by transform script.

Explaination of ignore=true; Refer from: https://docs.servicenow.com/bundle/rome-platform-administration/page/script/server-scripting/reference/r_TransformationScriptVariables.html

Variable name: ignore

Type: Boolean

Description: When set to true, skips or aborts the current import action. In onStart scripts, this variable aborts the entire transformation process. In onBefore scripts, this variable only skips the current row being transformed.