Discussions
Join us for complimentary one-day events around the world and step into a future fueled by AI and limitless potential. Explore new breakthroughs, sharpen your skills, and connect with experts who are shaping what’s next. Experience bold keynotes, interactive learning, and connections that span the global NetSuite community. Discover what's next at SuiteConnect Tour 2026.
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]];