- 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-06-2018 10:02 PM
hi Vikram,
I think there gotta be something with your code to copy attachment from RITM to sysapproval table.
How do u know the relationship is correct?
I suggest you check the sysapproval record by verifying whether you could see the attachment file through the UI16 (not portal) after you perform the copy attachment script.
I had just tried (OOTB Dev instance):
1. Open an existing sysapproval Record, upload a test text file attachment.
2. Get the sys_id and table for that approval record.
3. Open a ServicePortal Page that has 'Ticket Attachment' widget. In my instance, 'ticket' page.
https://xxxxxxxxxxx.service-now.com/sp?id=ticket&table=sysapproval_approver&sys_id=007a44badba52200a6a2b31be0b8f525&view=sp
4. Verify that attachment is there.
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-06-2018 10:30 PM
Hi Bryan,
Yes I tried as you advised. It is working fine.
I am not sure where I am making a mistake. I am setting approver in workflow only. There is no other code running.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2018 04:12 PM
hi Vikram,
in this case, seems like the part where you copy attachment from RITM to the approval record are not working.
how did u perform the copy of the attachment?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-09-2018 09:48 PM
I used below code to copy attachments from RITM to approver table to make attachment visible in 'Ticket Attachment' widget in portal.
(function executeRule(current, previous /*null when async*/)
{
var gr = new GlideRecord('sc_req_item');
gr.addQuery('sys_id',current.sysapproval);
gr.query();
gr.getRowCount();
while(gr.next()) {
GlideSysAttachment.copy("sc_req_item",gr.sys_id,'sysapproval_approver', current.sys_id);
}
})(current, previous);
I checked by placing logs. I could find that there is no sys id. Also to test, I directly attached in approver's table. That is was working fine.