ServiceNow Widget Debugging: Temporarily Set Any Field Value (Without Touching Code)
Let’s be honest… Service Portal debugging is slow. Every small change = 👉 Update script 👉 Save 👉 Reload 👉 Navigate back 👉 Test again Repeat that 10 time...
I came across many scenarios where there is an integration between two ServiceNow systems (not with Integration Hub) and we require to exchange attachments along with the records.
In this post I want to give solution for below use case.
A bidirectional incident integration configured between 2 ServiceNow systems. We need to enhance this with attachment exchange feature. When an attachment gets added to an incident in one system then that attachment should get attached to the related incident in the other system.
We can achieve this using eccq, soap message, and a script to trigger this soap message with attachment and incident details.
Create SOAP message with WSDL pointing to vendor instance ecc queue
Create a soap message with below details
Click on related link “Generate sample SOAP messages”
Open function “insert” from the related list named “SOAP Message Functions”
Create a script to trigger outbound call with attachment
There can be different places where we can write this script and it’s based on your approach. For example, we can write an after BR on attachment table with a filter condition to identify attachment gets added to an integrated incident and write this script in that BR.
var soapRequest = new sn_ws.SOAPMessageV2('Attachment to SNOW', 'insert');
soapRequest.setStringParameter('insert.agent','AttachmentCreator');
soapRequest.setStringParameter('insert.topic','AttachmentCreator');
/*** insert.name will be “anyname.file extension:filetype ***/
soapRequest.setStringParameter('insert.name','testfileupload2.png:image/png');
/*** insert.source will be incident:sysid of the record
for which you want to attach the attachment ***/
soapRequest.setStringParameter('insert.source','incident:8876c30edb723300cbde84da0b9619e2');
/*** If wring this script in BR,
check if you need to query attachment table or
you can simply use current object and
update this script accordingly ***/
var attch_gr = new GlideRecord('sys_attachment');
if(attch_gr.get('55e7e89cdb133300cbde84da0b961933')){
var stringUtil = new GlideStringUtil();
var sa = new GlideSysAttachment();
var binData = sa.getBytes(attch_gr);
// convert it to Encoded Data..
var encData = stringUtil.base64Encode(binData);
soapRequest.setStringParameter('insert.payload',encData);
}
var response = soapRequest.execute();
JSUtil.logObject(soapRequest.getRequestBody() ,'soapRequest ');
Written by
Let’s be honest… Service Portal debugging is slow. Every small change = 👉 Update script 👉 Save 👉 Reload 👉 Navigate back 👉 Test again Repeat that 10 time...
If you’ve worked with Multi-Row Variable Sets (MRVS) in ServiceNow, you’ve probably seen this requirement come up: “Allow users to add rows sometimes… but rest...
Learn how to embed the ServiceNow Virtual Agent in any website using the Portable Web Client, with support for SSO, CORS, and custom branding. Includes code sam...