Attachment not being transferred from record producer to HR ticket
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hello All,
I have created a record producer and added the variable " Attachment" (gave it a different name),
When users upload the attachment, it is being copied to the HR case being created, any advise?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday - last edited yesterday
Have you used a Before/Async Insert Business Rule to copy attachments from record producer to the HR case record.
If not , please create it.
Refer : KB2657281 Attachment Type Variable Does Not Add Files to Target Record in Record Producer
Cause
This is the default platform behavior: attachments uploaded via an Attachment Type variable in a Record Producer are not automatically copied to the target record. By design, these files are linked to the submission record, and additional configuration is required to transfer them to the generated record.
Resolution
1. Recognize that out-of-the-box, attachments from Attachment Type variables in Record Producers do not transfer to the target record.
2. Use a script or business rule to copy attachments from the submission record to the target record after the record is created.
For sample code:
(function executeRule(current, previous /*null when async*/) {
if (current.table_name == 'sc_re_item') { // <add your table name>
var rec = new GlideRecord('sys_attachment');
rec.addQuery('table_sys_id', current.table_sys_id);
rec.query();
while(rec.next()){
rec.table_name = 'sn_hr_core_case'; // Target HR Case Table rec.table_sys_id = producer.sys_id; rec.update();
}
}
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
OOTB the attachment won't be copied from attachment variable to target Record
you need to add script in record producer script to handle this
I created blog for this, check and enhance
Copying Attachments from a Record Producer's Attachment Variable to a Target Record in ServiceNow
In record producer script add this at the last
new global.VariableUtil().copyAttachment(producer.<variableName>,'<yourTargetTableName>', current.sys_id);
💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
Hi @samirmeroua
You can use producer.variable_name(backend of the attachment variable) to access the backend value of the attachment variable in the Record Producer script.
Try this script
