saveResponseBodyAsAttachment without table name/sys_id

Appli
Mega Sage
Mega Sage

Hi, I would like to retrieve Excel file from external source, save it as attachment in sys_attachment table, process and delete it finally.

Or just retrieve it, save in memory, and process. Closest guidelines I found - here

A challenge - saving an attachment requires adding target table (like incident) and sys_id (like its incident record):

request.saveResponseBodyAsAttachment(tablename, recordSysId, filename);

However my application does not interact with any table in SN, hence the method above does not work to me. Attaching to the script itself does not look to be a nice solution either. Any workaround?

Thank you in advance.

Hope it helps
5 REPLIES 5

The GlideExcelParser API can parse Excel spreadsheets in code, using an input stream to an attachment accessed via its sys ID using the GlideSysAttachment API.

You can create sys_data_source records on the fly -- or reuse the same record -- and attach the spreadsheet as an attachment to that record, deleting the attachment when your code is done processing the spreadsheet.