how to copy attachments in incident from one instance to another instance via rest integration
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-04-2019 04:58 AM
how to copy attachments in incident from one instance to another instance via rest integration

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-04-2019 05:02 AM
There is an attachment reset api.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-04-2019 06:26 AM
REST has an attachment API that can make this a bit easier.
and also please refer these below links might be helpful for you.
Copying attachment from one instance to another
Copying attachment from one instance to another+
Please mark as Correct Answer and Helpful, if applicable.
Thanks!
Abhishek Gardade
Hexaware Technologies
Abhishek Gardade

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-04-2019 06:28 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-04-2019 02:47 PM
Hi Buddy,
Write the below code in BR to send attachment from yours instance (source) to another instance (target):
Prerequisite : 1.must create a Rest message
2.create a BR on respective table, in this caste it an Incident
(function executeRule(current, previous /*null when async*/) {
try {
var sa = new GlideRecord('sys_attachment');
sa.addQuery('table_name', 'incident');
sa.addQuery('table_sys_id', current.sys_id);
sa.query();
while (sa.next()) {
var glide = new GlideSysAttachment();
var binData = glide.getBytes(sa);
var payload = GlideStringUtil.base64Encode(binData);
var file_name = sa.getValue('file_name');
var content_type = sa.getValue('content_type');
var r = new sn_ws.RESTMessageV2('Outbound_name', 'postAttachment');
r.setRequestHeader("Content-Type", "application/json"); //This is necessary in order to make use of 'Outbound HTTP Requests' logging. Without it, the outbound request body is not recorded in the log.
r.setStringParameterNoEscape('target_reference', current.u_client_ref);
r.setStringParameterNoEscape('target_number', current.number);
r.setStringParameterNoEscape('target_payload', payload);
r.setStringParameterNoEscape('target_file_name', file_name);
r.setStringParameterNoEscape('target_content_type', content_type);
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
gs.log('XXXX attachment ' + count + ' request body: ' + current.number + ': ' + r.getRequestBody());
gs.log('XXXX attachment ' + count + 'responseBody: ' + current.number + ': ' + responseBody);
gs.log('XXXX attachment ' + count + 'httpStatus : ' + current.number + ': ' + httpStatus);
} //end looping through the attachments that need to be sent.
}
catch(ex) {
var message = ex.getMessage();
gs.log('XXXX ERROR in Send Attachments: ' + message);
}
})(current, previous);
Do mark it as correct answer and also mark it helpful if this resolves your query!!
regards,
Ajay