- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2021 09:20 AM
Hi:
I created an attachment variable on a record producer. It seems that when the user adds the attachment and submits the form, it is not getting attached to the incident record created by the record producer. I see it creates the highlighted as example but does not get attached to the incident record.
Please advise.
Thank you, Rita
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2021 11:04 AM
You can use following script in record producer script section to attach the attachment to current record, you can update it accordingly
var gr = new GlideRecord('sys_attachment');
if(gr.get(producer.attachment)){ //attachment field name
gr.table_name='incident'; //copy to table name
gr.table_sys_id=current.sys_id;//copy to record sys_id
gr.insert();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2021 10:13 AM
You have to create a new field as file attachment and map the record producer attachment variable to it.
- In a record producer, when the variable is mapped to a task table field. This variable can be mapped only to the File Attachment field type of a task table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2021 10:25 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-11-2021 11:04 AM
You can use following script in record producer script section to attach the attachment to current record, you can update it accordingly
var gr = new GlideRecord('sys_attachment');
if(gr.get(producer.attachment)){ //attachment field name
gr.table_name='incident'; //copy to table name
gr.table_sys_id=current.sys_id;//copy to record sys_id
gr.insert();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2021 05:48 PM
Although this works, it would be better to use gr.update(); instead of gr.insert();
That way you simply point the existing attachment to the proper record instead of making a copy