- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2021 06:12 PM
Hi Community, I have Created a attachment variable on the record producer. Ant that task is submitted by the to-do task. i.e "Submit Catalog item". But when the attachment is added that attachment is not showing on the HR case.
I have mapped the field with "File_attachmnet " field type on HR case. i also tried to add code on record producer to copu the attachment. But its not working can any one help me with this ?
var gr = new GlideRecord('sys_attachment');
if(gr.get(producer.attach_covid_report)){ //attachment field name
gr.table_name='HR Employee Relations'; //copy to table name
gr.table_sys_id=current.sys_id;//copy to record sys_id
gr.insert();
Solved! Go to Solution.
- Labels:
-
HR Service Delivery
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2021 08:23 AM
I was able to resolve this by adding a widget and on submit client script . thank you verymuch
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2021 10:40 PM
Please try Attachment copy API.
Thanks,
Gaurav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2021 10:49 PM
It won't work directly using map to field
I have shared working solution here
just enhance as per your requirement
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2021 11:26 PM
I tried with your code and it works for me with some correction.
1. Correct the table name from label 'HR Employee Relations' to actual case table name.
var gr = new GlideRecord('sys_attachment');
if(gr.get(producer.u_attachment)){ //attachment field name
gr.table_name='sn_hr_core_case_operations'; //copy to table name
gr.table_sys_id=current.sys_id;//copy to record sys_id
gr.insert();
}
2. Check the attachment table application access settings are configured as below.
3. Run as background script to clear table cache:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-25-2021 08:23 AM
I was able to resolve this by adding a widget and on submit client script . thank you verymuch