Andrew Nguyen
05/19/2025, 3:21 AMCeligo AI
05/19/2025, 3:21 AMAI generated answer (using internal Slack threads):In a Suitelet, to get the files attached to an invoice, you would need to use the
N/file
and N/record
modules of SuiteScript. Here's a general idea of how you can do it:
1. Load the invoice record using record.load
method.
2. Get the count of attached files using record.getLineCount
method with {sublistId: 'recmachcustrecord_file'}
.
3. Loop through each line of the sublist and get the internal id of each file using record.getSublistValue
method with {sublistId: 'recmachcustrecord_file', fieldId: 'custrecord_file', line: i}
.
4. Load each file using file.load
method with the internal id obtained in the previous step.
Here's a sample code snippet:
javascript
var record = require('N/record');
var file = require('N/file');
var invoiceRecord = record.load({
type: record.Type.INVOICE,
id: 'your_invoice_id'
});
var fileCount = invoiceRecord.getLineCount({sublistId: 'recmachcustrecord_file'});
for (var i = 0; i < fileCount; i++) {
var fileId = invoiceRecord.getSublistValue({
sublistId: 'recmachcustrecord_file',
fieldId: 'custrecord_file',
line: i
});
var fileObj = file.load({
id: fileId
});
// Now you have the file object and can do whatever you want with it
}
Please replace 'your_invoice_id'
with the actual internal id of your invoice.
******
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
05/19/2025, 3:21 AMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.841255069
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.83179158
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.820865571
Celigo AI
05/19/2025, 3:21 AM