Discussions
Narrative Insights is Temporarily Unavailable due to an Infrastructure Issue. Learn how This Impacts Your Account and What to Expect While the Feature is Disabled.
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]];