Benjamin Cookson
03/18/2026, 9:15 PMCeligo AI
03/18/2026, 9:15 PMAI generated answer (using internal Slack threads):To access attached files on a transaction record using SuiteScript, you can use the
N/search module to create a search that joins transactions with their file attachments. Here is an example of how you can do this:
javascript
const tranId = '123456';
const salesOrderSearchObj = search.create({
type: 'salesorder',
filters: [
['internalid', 'anyof', tranId],
'AND',
['type', 'anyof', 'SalesOrd'],
'AND',
['mainline', 'is', 'T'],
],
columns: [
search.createColumn({
name: 'internalid',
join: 'file',
label: 'Internal ID',
}),
search.createColumn({
name: 'name',
join: 'file',
label: 'Name',
}),
search.createColumn({ name: 'tranid', label: 'Document Number' }),
],
});
const searchResultCount = salesOrderSearchObj.runPaged().count;
log.debug('salesOrderSearchObj result count', searchResultCount);
salesOrderSearchObj.run().each(function (result) {
return true;
});
This script creates a search on the 'salesorder' type, with filters to specify the transaction ID, type, and mainline. The columns specify the fields to be returned in the search results, including the internal ID and name of the attached file.
If you want to get the file id from a custom record, you can use the getLineCount method with the 'mediaitem' sublistId:
javascript
var fileCount = myCustomRecord.getLineCount({sublistId:'mediaitem'});
******
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
03/18/2026, 9:16 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.86529541
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.863464355
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.861389279
Celigo AI
03/18/2026, 9:16 PM