RE: created script to attach file from Vendor bill to invoice

fileIds.forEach(function(fileId) {
if (fileId) {
log.debug(‘Attempting to Attach’, ‘File ID: ‘ + fileId + ‘ to Invoice ID: ‘ + invoiceId);

try {
var fileObj = file.load({ id: fileId });
log.debug(‘File Loaded’, ‘File ID: ‘ + fileId);

log.debug(‘Attach Parameters’, {
record: {
type: ‘file’,
id: fileObj.id
},
to: {
type: ‘invoice’,
id: invoiceId
}
});

if (fileObj && invoiceId) {
var id = record.attach({
record: {
type: ‘file’,
id: fileObj.id
},
to: {
type: ‘invoice’,
id: invoiceId
}
});
This is the code to attach but getting  below error
System- [“attachRecord(N/recordImpl)”,”<anonymous>(/SuiteScripts/new File attaachment.js:67)”,”<anonymous>(/SuiteScripts/new File attaachment.js:47)”,”execute(/SuiteScripts/new File attaachment.js:19)”] Remove
2 View Error Error Attaching File
any help

Renuka Rookie Asked on April 21, 2025 in SuiteScript.
Add Comment
2 Answers

All looks good

Issue is resolved . Working now

Rookie Answered on April 22, 2025.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.