copy attachments from incident to knowledge

Thej1
Tera Expert

Hi,

 

Created a knowledge article from an incident is resolved. (without plugin)

https://docs.servicenow.com/bundle/washingtondc-it-service-management/page/product/incident-manageme...

 

But we also want to copy attachments too.

 

I wrote a BR, but it is not working. Could you please help me with this ?

 

Thanks

 

@Amit Gujarathi @SANDEEP28 @Community Alums @Arpan Baishya @Mark Anderson @Mark Ma @Kieran Anson 

8 REPLIES 8

VaishnaviShinde
Kilo Sage

Hello @Thej1 ,

 

Please add below code.

 

 

 

 var scTask = new GlideRecord('sc_task'); // Add your table name
    scTask.addQuery('sys_id', current.sys_id);
    scTask.query();
    gs.info('Sctask Count before insert br:' + scTask.getRowCount());
    if (scTask.next()) {
        GlideSysAttachment.copy('sc_req_item', scTask.request_item.sys_id, 'sc_task', scTask.sys_id); // Change the table name and record sys_id as per your requirment
    }

 

 

 

Please Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.

 

Regards,

Vaishnavi Shinde

Arpan Baishya
Kilo Sage

Hi @Thej1,

 

Consider using Flow Designer in this regard. You can define a record-based trigger with the necessary table name and conditions. Then, you may use Attachment-related actions such as Get Attachments on Record (getting the count and list of attachments) and Copy Attachment (place this action inside a For Each loop) in order to copy attachments from Incident to Knowledge.

 

Let me know if this helps.

Agreed, this is the most maintainable approach. Below Flow is an example and took less than 5 minutes

KieranAnson_0-1715688852380.png

 

Hi @Kieran Anson ,

 

In the 5th step, i kept source attachment record as like this.

Thej1_0-1715773097296.png

It is throwing an error in the execution as 

Thej1_1-1715773138582.png

 

Could you help me with this ?

 

Thanks