- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2018 06:33 PM
Hi all,
I am trying to copy attachments from RITM to sysapproval table. But it doesn't work. Relationship is working fine. But relationship attachment won't show in portal 'Ticket Attachment' widget.
My question is how to copy attachment from RITM to approval table and make it display in 'Ticket Attachment' widget.
Thanks in advance.
Regards,
Vikram
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-14-2018 12:22 AM
Hi Bryan,
A big thanks for your support and your valuable time. It finally worked after making below changes,
Table - sysapproval_approver
Async BR
(function executeRule(current, previous /*null when async*/)
{
var gr = new GlideRecord('sc_req_item');
gr.addQuery('sys_id', current.sysapproval);
gr.query();
if(gr.next()) {
GlideSysAttachment.copy('sc_req_item', gr.sys_id, 'sysapproval_approver', current.sys_id);
}
})(current, previous);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2018 10:29 PM
hi Vikram,
The script seems to works fine just that u will have to be careful with the source table and destination table.
For OOTB, RITM -> sc_request -> sysapproval_approver
The way i verify it is with
1. Open a new RITM with approver record.
2. Navigate to RITM/sc_request record and get its sys_id.
3. Navigate to the approval record and get it's sys_id.
run the following code in background script:
var gr = new GlideRecord('sc_request');
gr.addQuery('sys_id','5312074c4fa02300df6d4ebf9310c7f5');
gr.query();
gs.print(gr.getRowCount());
//Run this part to verify the source record details.
while(gr.next()) {
var copyAtt = new GlideSysAttachment();
copyAtt.copy("sc_req_item",gr.sys_id,'sysapproval_approver','eb12474c4fa02300df6d4ebf9310c71f');
}
This is how I make it work and hopefully this help you to debug your program.
good luck.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2018 10:55 PM
I tried with your background script. It works fine.
My scenario/configuration,
1. End user raise request from Portal with attachment.
2. REQ will be generated without attachment.
3. RITM will be created with attachment.
4. Approver will be created without attachment.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2018 05:49 PM
hi Vikram,
This is the part onward that you need to check the Copy Attachment being triggered.
4. Approver will be created without attachment.
Verify on the actual Approval Record the "Copy Attachment" script had been successful.
Before you even verify it in the portal (in 'Ticket Attachment' ).
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2018 04:19 PM
When I try uploading attachments manually it works. But via request it is not workingl. I am totally confused where to work?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2018 04:48 PM
hi vikram,
where does your copyattchment business rule being added to?
At which steps your copy attachment happened?
1. End user raise request from Portal with attachment.
2. REQ will be generated without attachment.
3. RITM will be created with attachment.
4. Approver will be created without attachment.
If you are not sure how to check the sequence, insert more gs.log/print to verify...
Add some gs.log in your executeRule that contain copy attachment and verify whether it had been triggered when u perform step 1,2,3,4 above.
hope this helps.