- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2025 11:58 AM
I want to send the attachment from one instance to another instance, but it is not working
End point:https://instance_name.service-now.com/api/now/table/ecc_queue
Payload:{
"source":"staging_table:${snow_source}",
"name":"${snow_fileName}",
"agent":"${snow_agent}",
"topic":"${snow_topic}",
"payload":"${snow_payload}"
}
Business rule:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2025 07:20 AM
update as this, no need to use GlideRecord again on sys_attachment as you can directly pick the current object
var StringUtil = new GlideStringUtil();
var attachments = new GlideSysAttachment();
var fileName, contentType;
try {
var binData = attachments.getBytes(current);
var encData = StringUtil.base64Encode(binData);
var s = new sn_ws.RESTMessageV2('EDOH', 'Create_Attachment');
s.setStringParameter('snow_source', current.table_sys_id);
s.setStringParameter('snow_payload', encData);
s.setStringParameter('snow_topic', 'AttachmentCreator');
s.setStringParameter('snow_agent', 'AttachmentCreator');
s.setStringParameter('snow_fileName', current.file_name + ':' + current.content_type);
var response2 = s.execute();
var responseBody2 = response2.getBody();
gs.log("Create Attachment" + responseBody2);
var status = response2.getStatusCode();
gs.log("Create Attachment" + status);
} catch (ex) {
var message1 = ex.getMessage();
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2025 07:23 AM
Hi Ankur,
Thanks for your help.
Finally with sys_attachment after insert with below code is working fine as expected,
Condition:current.table_name == 'incident'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2025 11:41 PM
Can someone please assist here asap. This is very urgent
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-22-2025 11:53 PM
you want to transfer files between instances right?
if yes then check these links and it has working solution
Unable to send attachment via REST
Business rule to send attachment to 3rd Party Tool via REST
Send attachment via rest message
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2025 04:27 AM
Hi Ankur,
It is working when i attach the attachment to the incident,the same gets attached to the another instance. But the issue here is when i attach another attachment or when i update the incident, it is sending the attachment again to the another instance. I have written the below code to validate the existing attachments but still not working
Please review the code and help me
Business Rule : After Update
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2025 05:04 AM
send the files for the 1st time when incident is created via after insert business rule on incident.
From next time onwards when new file is added have after insert BR on sys_attachment table
condition: current.table_name == 'incident'
Script:
// your logic of RestMessage
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader