Need to attach an attachment from Record procedure
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2023 04:55 AM
Hi All,
I have created a Record Procedure (RP). In that RP I have created Attachment Variable.
When User Clicks on submit button that attachment should be attached to target Table.
But I'm unable to attach it in Target Table. Anyone please help me on this issue.
Thanks & Regards,
Anji.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2023 04:58 AM
Hi @Bunny
What have you tried already?
Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2023 05:45 AM
I have shared solution for this few years ago
Disable ZZ_YY prefix from attachment when added through record producer
sharing it again here
1) I created Async After Insert BR on the target table
2) Script as this
a) Remove the ZZ_YY
b) Then use the Copy Attachment
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var gr = new GlideRecord("sys_attachment");
gr.addQuery("table_name", "ZZ_YY" + current.getTableName());
gr.addQuery("table_sys_id", current.sys_id);
gr.query();
if (gr.next()) {
gr.table_name = current.getTableName();
gr.update();
new global.VariableUtil().copyAttachment(gr.sys_id, current.getTableName(), current.sys_id);
}
})(current, previous);
Output:
1) The file added to the record
2) The file present on the attachment variable
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