Discussions
Join the NetSuite community to innovate, connect, and discover what’s next.
SuiteWorld brings thousands of innovators, builders, and leaders together to learn, connect, and shape what’s next. This October, explore how to build a stronger foundation for growth through inspiring keynotes, major product reveals, hands-on sessions, and unforgettable moments—all in one place for our biggest event of the year. Register now
NetSuite Custom API for Publish Attachment
Greeting Gurus,
i have my script to push attachment and then tie it to a given JournalEntry
/**
@NApiVersion 2.1
if (!fileName || typeof fileName !== 'string') {
throw error.create({
name: 'INVALID_FILENAME',
message: 'Invalid or missing filename'
});
}
const extension = fileName.split('.').pop().toLowerCase();
log.debug('getFileType', 'Detected extension: ' + extension);
// Map of supported file types
const fileTypeMap = {
'txt': 'PLAINTEXT',
'pdf': 'PDF',
'csv': 'CSV',
'xls': 'EXCEL',
'xlsx': 'EXCEL',
'doc': 'WORD',
'docx': 'WORD',
'jpg': 'JPEG',
'jpeg': 'JPEG',
'png': 'PJPGNG',
'gif': 'GIF'
};
if (!fileTypeMap[extension]) {
throw error.create({
name: 'INVALID_FILE_TYPE',
message: `Unsupported file extension: ${extension}`
});
}
// Get the file type constant
const fileType = file.Type[fileTypeMap[extension]];