Eric Schultz
04/02/2025, 6:30 PMCeligo AI
04/02/2025, 6:30 PMAI generated answer (using internal Slack threads):To load a record and access the file attachments in SuiteScript, you can use the
N/file
and N/record
modules.
First, you need to load the record using the N/record
module's load
method. However, the attachments are not directly accessible from the loaded record.
To access the attachments, you need to perform a search on the record using the N/search
module. You can use a file join on your custom record in the search to get the attached files.
Here is a sample code snippet:
javascript
var record = require('N/record');
var search = require('N/search');
// Load the record
var myRecord = record.load({
type: 'customrecord_my_custom_record',
id: '123'
});
// Perform a search to get the attached files
var mySearch = search.create({
type: 'customrecord_my_custom_record',
filters: [
['internalid', 'anyof', '123']
],
columns: [
'internalid',
'name',
'file'
]
});
mySearch.run().each(function(result) {
// Access the file from the result
var file = result.getValue(result.columns[2]);
// Do something with the file...
return true;
});
In this code, replace 'customrecord_my_custom_record'
with your custom record type and '123'
with the ID of the record you want to load. The search will return all files attached to the record.
******
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/02/2025, 6:30 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.808439136
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.803127408
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.802993417
Celigo AI
04/02/2025, 6:30 PMCeligo AI
04/02/2025, 6:32 PM