- 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-24-2025 07:06 AM
Hi Ankur,
Now, duplicates files are not getting attached .when i attached the first doc ex:test.doc, it got attached on other end as test.doc but when i attached the second document as ex:book1.xlsx, again instead of book1.xlsx,test.doc is getting attached. That is the only one issue we have right now. Please help to fix that
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2025 07:07 AM
Wrote business rule on sys_attachment after insert
Below code:
- 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'