Can we include attachment on the import set record to the target record?

edgar_evangelis
Tera Contributor

How do we include/exclude attachment from the import set table to the target table during transform?

2 REPLIES 2

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Edgar,

 

By default, attachments are not included when you import the data via Import set Tables. However, you can use the Attachment API to include attachments.

Reference:

https://docs.servicenow.com/bundle/geneva-servicenow-platform/page/integrate/inbound_rest/reference/r_AttachmentAPI-POST.html

https://community.servicenow.com/community?id=community_question&sys_id=970903e1db5cdbc01dcaf3231f9619ce

 

Thanks,

Pradeep Sharma

sachin_namjoshi
Kilo Patron
Kilo Patron

You can use the attachment API in a script.

 

 

 

Or you can do it via script by inserting into ecc queue:

 

Convert your attachment to base64

 

 

 

var inc = new GlideRecord('incident');

 

inc.query();

 

while(inc.next()){

 

 

 

var ecc = new GlideRecord('ecc_queue');

 

ecc.initialize();

 

ecc.agent = 'AttachmentCreator';

 

ecc.topic = 'AttachmentCreator';

 

ecc.name = 'file_name.xls:application/vnd.ms-excel'   // or whatever the file name is + its content-type

 

ecc.soruce = 'incident:' + inc.sys_id;

 

ecc.payload = '<attachment base 64>';

 

ecc.insert();

 

 

 

}

 

Regards,

Sachin