saveResponseBodyAsAttachment without table name/sys_id
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2022 08:18 AM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-16-2022 07:51 AM
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.