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

hi Ankur,

 

it is not working.Actually i have used  after insert  BR because first pdf should get automatically attached to the record after submitting the record only after that i could take the atachment from sys_attachment table.

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

Still its not working 

 

Hi,

it worked for me

your BR is on which table and please share complete BR script and BR configuration image

Regards
Ankur

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

find_real_file.png

find_real_file.png