How to copy attachment from sys_attachment table to a field

Sarika S Nair1
Kilo Sage

How to copy attachment from sys_attachment table to a field of file attachment type in a custom table.

1 ACCEPTED SOLUTION

Hi,

then the same script can be used to update the attachment field

var att = new GlideRecord('sys_attachment');

att.addQuery('table_sys_id', current.sys_id);

att.query();

if(att.next()){

current.attachment_fieldName = att.sys_id;
current.setWorkflow(false);
current.update();

}

Regards
Ankur

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

View solution in original post

20 REPLIES 20

Kajal Goti
Mega Guru

Hi,

 

Can you please explain more what exactly the requirement??

how you guys store attachment in sys_attachment table like manually on records bla bla....

on which table the file attachment field is ?

 

vikas shukla
Kilo Guru

Hii @Sarika,

Trying to use Flow Designer.You can Perform Very Easily and Copy the Attachment From Attachment table to custom table . In Flow Designer You Can use Lookup Attachment Records Action to copy the attachment Form the Table And Moved to Custom table.

Please Mark Correct.

Regards,

Vikas

Hi vikas ,

I have created a flow designer. But the file is not get copied to my file attachment field.

I have used look up record and update record actions in flow designer.

Check the below Attachment File

I have used the same . But still the file is not copied to the field.