Import multiple attachments from an excel to the sys_attachement table servicenow

Priya103
Tera Contributor

Hi All,

For example, if there are multiple attachments present in an excel sheet along with column data, is it possible to insert each of these attachments into the sys_attachment table. Any suggestions??

7 REPLIES 7

@Priya103 

I don't think it's supported.

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

@Priya103 

Thank you for marking my response as helpful.

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

sumanta pal
Kilo Guru


Yes, it is possible to insert attachments from an Excel sheet into the sys_attachment table in ServiceNow. However, it's not a straightforward process as ServiceNow does not provide a direct way to import attachments via Excel. Here's a workaround:

1. First, you need to convert your attachments into Base64 format. There are several online tools available for this purpose.

2. Once you have the Base64 string, you can add it to your Excel sheet.

3. Now, you can import the Excel sheet into ServiceNow using the Import Set functionality.

4. After the import set is created, you can write a script to read the Base64 string from the imported record and create an attachment.

Here is a sample script:

javascript
var importSetRec = new GlideRecord('u_import_set_table'); //replace with your import set table
importSetRec.query();

while(importSetRec.next()){
var base64String = importSetRec.u_attachment; //replace with your base64 string field
var attachment = new GlideSysAttachment();
attachment.write(importSetRec, 'attachment.txt', 'text/plain', base64String);
}


This script will create an attachment for each record in the import set table.

Please note that this is a workaround and might not be suitable for all use cases. Always test in a sub-production instance before implementing in production.


nowKB.com