- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2020 12:49 AM
I want to copy attachment from child record to parent record. The parent record lives on parent table sn_customerservice_case. The child record lives on sn_customerservice_ref
This script is running on my Child table with the following conditions
1. Before
2. Insert/Update
Here is my script, but it's not working
var gr= new GlideRecord('sn_customerservice_case');
gr.addQuery('sys_id',current.sn_customerservice_case);
gr.query();
if(gr.next()){
GlideSysAttachment.copy("sn_customerservice_ref",current.sys_id,"sn_customerservice_case",gr.sys_id);
}
gr.update();
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2020 07:48 AM
The final solution that I used to get it to work:
Insert/Update
Async
Script:
GlideSysAttachment.copy("sn_customerservice_ref",current.sys_id,"sn_customerservice_case",current.u_case_number.sys_id);
//Case number = u_case_number: This is the reference field to the parent record
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2020 12:56 AM
Hi Lexy ,can you please tell me on which table you have written your BR?
Regards,
Ishita
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2020 01:05 AM
Hi Lexy, if you have written this BR on your child table and you want to make an update on a related table then you should write After Insert /Update BR.
Hope this helps.
Regards,
Ishita Shrivastava.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-06-2020 01:08 AM
Hi,
best to do is to make your BR async for avoid any performance issue, as suggested also by Goran to the below thread, it will work:
If I have answered your question, please mark my response as correct and/or helpful.
Thank you very much
Cheers
Alberto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-07-2020 07:48 AM
The final solution that I used to get it to work:
Insert/Update
Async
Script:
GlideSysAttachment.copy("sn_customerservice_ref",current.sys_id,"sn_customerservice_case",current.u_case_number.sys_id);
//Case number = u_case_number: This is the reference field to the parent record