Eric Schultz
04/01/2025, 8:50 PMCeligo AI
04/01/2025, 8:50 PMAI generated answer (using internal Slack threads):In SuiteScript 2.x, you can load a record and access the file attachments by using the
N/record
and N/file
modules.
First, you need to load the record using the N/record
module's load
method. Here is a sample code snippet:
javascript
var record = require('N/record');
var myRecord = record.load({
type: 'customrecord_my_custom_record',
id: '123'
});
Once the record is loaded, you can access the sublist "Files" to get the attached files. Here is a sample code snippet:
javascript
var fileCount = myRecord.getLineCount({sublistId: 'mediaitem'});
for (var i = 0; i < fileCount; i++) {
var fileId = myRecord.getSublistValue({
sublistId: 'mediaitem',
fieldId: 'mediaitem',
line: i
});
}
The mediaitem
sublist contains the attached files. The mediaitem
field in this sublist holds the internal ID of the file.
After getting the file ID, you can load the file using the N/file
module's load
method. Here is a sample code snippet:
javascript
var fileModule = require('N/file');
var myFile = fileModule.load({
id: fileId
});
Now, you have the file loaded and you can use it as per your requirement.
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
04/01/2025, 8:50 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.846978605
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.842610359
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.840865791
Celigo AI
04/01/2025, 8:50 PM