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

Julio Valdez JR
Giga Contributor

Are you trying to avoid touching a table? If not, you could create a record in the Import Sets table (sys_import_set) and attach it there. The record will be automatically cleaned up after some time. 

Hi, thanks. Idea is to retrieve the file, extract one row from it, put it to remote table. I clearly do not need any usage of DB table in between unless it is absolutely required (if there are no any other ways to accomplish an objective).

Hope it helps

Hope it helps

Rogers Cadenhe1
Giga Guru

Since your Excel file doesn't need to be associated with a record or table, it sounds like you should use data sources and transform maps instead. The data will be stored in an import set temporarily and deleted automatically later.

Create a data source using a static version of the Excel file so that you can create the transform map and process the fields in the spreadsheet. Then depending on how you get the Excel file, use the File Path and Connection URL fields in your sys_data_source record to determine how to retrieve it. If either of those fields changes, use a scheduled job to change the record.

Hi. Retrieving Excel file in Data Source will still require to use an import set table (staging), I am just looking for a way how to load/process the data "on the fly" without storing them neither in temporary nor production tables. Apparently it is not supported OOB, thanks anyway.

 

Hope it helps