Attachment not being transferred from record producer to HR ticket

samirmeroua
Tera Contributor

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?

 

2 REPLIES 2

samirmeroua
Tera Contributor
 

Tanushree Maiti
Tera Sage

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);

 

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin: