copy attachments from KB artcical to notifications email template

sushma9
Tera Contributor

Hi All,

I am copying the attachments  from Kb article to notification email and i  writing the email script to do that but i its not working .Please find the attached script below and let me know if anything has to be modified.

 

script :

 var grAttach = new GlideRecord("sys_attachments");
    grAttach.addQuery("table_name", "kb_knowledge");
    grAttach.addQuery("sys_id", "56dba1121b36b998bcae5457604bcbdc")
    grAttach.query();
    if (grAttach.next()) {
        GlideSysAttachment.copy('kb_knowledge', '56dba1121b36b998bcae5457604bcbdc', 'sys_email', current.sys_id);
    }
9 REPLIES 9

Ankur Bawiskar
Tera Patron
Tera Patron

@sushma9 

email notification is on which table? please share screenshot.

try this once

var grAttach = new GlideRecord("sys_attachments");
grAttach.addQuery("table_name", "kb_knowledge");
grAttach.addQuery("table_sys_id", "56dba1121b36b998bcae5457604bcbdc"); // I updated here
grAttach.query();
if (grAttach.next()) {
GlideSysAttachment.copy('kb_knowledge', '56dba1121b36b998bcae5457604bcbdc', 'sys_email', current.sys_id);
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar 

notification are in  sc_req_item table and when ever any request is created then one notification will trigger and i need to attach the attachments which is there in the Kb Artical . I have created email script to attaché tgem in the notification and its not working .is there any other way to add them in the notifications  like Business rules ?

 

 

@sushma9 

RITM is created and will have some files attached. but how are you linking RITM and KB?

Also when should the file be copied to KB?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Ankur Bawiskar 

Once ritm is created I am tiring the notification  and I have created one Kb artical and i have added  one attachment in the Kb artical  .Once the notification is triggered  In that notification i have to add the attachments which is present in the Kb artical.