Copy attachments from an RITM request to the sys_approval_approver table

Peter Williams
Kilo Sage

good day, 

i have a business case here.

When a user submit a catalog item, it will create an RITM request with an attachment but if the user forgets to attach and item, i would like to have the ability for the user to attach the document onto the open RITM request and then have that attachment to appear for the Approver in the email.

 

ex.

the item highlighted is a newly attached Doc

PeterWilliams_0-1723816242383.png

 

i want that doc to now appear for the approver here:

 

PeterWilliams_1-1723816284742.png

 

i tried business rules on the sc_req_item table and sys_attachment but nothing seem to work and i am stuck here

 

PLEASE HELP...

 

 

10 REPLIES 10

Ayushi12
Mega Sage

Hi @Peter Williams 

You can write a business rule on sysapproval_approver 

attachApproval();



function attachApproval()

{

var gr = new GlideRecord('sc_req_item');

gr.addQuery('sys_id', current.sysapproval);

gr.query();

  while(gr.next()) {

GlideSysAttachment.copy("sc_req_item", gr.sys_id, "sysapproval_approver", current.sys_id);

  }

}

If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful."

Thanks!

i tried it before as i found it on the treads  and not working

PeterWilliams_0-1723817354694.png

 

PeterWilliams_1-1723817386373.png

 

 

Hi @Peter Williams 
You have removed the default syntax of Business rule.Please don'nt remove the code and add code where     // Add your code here is mentioned 

(function executeRule(current, previous /*null when async*/) {

    // Add your code here

})(current, previous);
Ayushi12_0-1723818232386.png

If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful."

Thanks!

same deal, not attaching 

PeterWilliams_0-1723818850796.png

 

 

PeterWilliams_1-1723818872205.png

 

PeterWilliams_2-1723818894079.png

 

 

PeterWilliams_3-1723818917233.png