SOAP Attachments to 3rd party servicenow instance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2017 11:15 PM
Hi All,
Can any one help me with my need. we have integration with 3rd party servicenow instance inc-to-inc. we also need to send attachments to and fro.
I read an article explaining how to send attachments to servicenow in servicenowguru. it seems we need to have SYS_ID of the 3rd party ticket before we send the attachment. but we can't find the sys_id in our instance.
How to get the sys_id first from the 3rd party instance and then pass the attachment from our instance to their instance
.
servicenowguru article:
https://www.servicenowguru.com/integration/sending-attachment-servicenow/
thanks,
sry
- Labels:
-
Integrations
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2017 11:24 PM
Hi sry,
This is the out of box Attachment WSDL for receiving attachment.
you can use business rules to send attachment to third-party and use transform map to receive incoming attachments from third-party.
For SOAP there is a limitation of size 5MB, means you cannot receive attachments of size greater than 5MB from SOAP.
If you need any help , ready to assist.
Thanks & Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2017 11:32 PM
Hi sry,
If you had integrated with the 3rd party system you would be getting the sys_id(Unique_id) for that system in Soap response.
You will find this video helpful.
https://www.youtube.com/watch?v=MlH0YB7faI4
Still you face problems get back to me, i can help(code) you in this.
Regards
Neeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2017 11:37 AM
Hi Neeraj, you may already knew this. just thought it will be helpful for others who search for solutions.
we have written onAfter Insert Business rule to trigger outbound soap service on sys_attachment table whenever an attachment is inserted. Below is the codesnippet we used to accomplish the thing.
also in our instance we find that there are two OOB business rules on ECC_QUEUE. one is "attachment creator sensor" and second one is "attachment creator". you don't need "attachment creator" if you are already on fuji or above, you can deactivate it.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var base64attachment = '';
var inc = new GlideRecord('incident');
inc.addQuery('sys_id',current.table_sys_id);
inc.query();
if(inc.next()){
venTicket = inc.ven_ticket;
ticket = inc.number;
}
var attachmentIS = new GlideSysAttachmentInputStream(current.sys_id);
var bytearrayOS = new Packages.java.io.ByteArrayOutputStream();
attachmentIS.writeTo(bytearrayOS);
base64attachment = GlideBase64.encode(bytearrayOS.toByteArray());
var s = new SOAPMessage('your outbound soap webservice', 'your outbound function');
s.setStringParameter('refTicketNumber', ticket);
s.setStringParameter('ticketNumber', venTicket);
s.setStringParameter('attachmentPayload', base64attachment);
s.setStringParameter('attachmentName',current.file_name);
//you may need to pass other information along with the above like transactionID,timestamp,sender,receiver etc.depends on the field mapping
s.post(true);
})(current, previous);