Approvers can't see RITM attachments

Vikram3
Giga Guru

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

 

1 ACCEPTED SOLUTION

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);

View solution in original post

10 REPLIES 10

Bryan Tay3
Mega Guru

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.

find_real_file.png

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.

find_real_file.png

Hope this helps.

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.

Bryan Tay3
Mega Guru

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?

 

created 3m ago in Developer Community
 

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.