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
Get the lineCount of attachements and notes
Goodafternoon,
is there a way to get the lineCount from attachment (mediaitem) and the notes('note')?
I wanted to create a script, that if there are any attachments and/notes a field get true, so the users can quickly see if there are any attachements and/or notes. before checking communication subtab.
I created below SuiteScript:
const beforeLoad = (context) => {
log.debug('attachment and note script','loaded')
var currentRecord = context.newRecord;
var recType = currentRecord.type.purchaserequisition;
if(context.Type == recType){
let countOfAttachment = currentRecord.getLineCount({
sublistId : 'mediaitem',
});
let countOfNotes = currentRecord.getLineCount({
sublistId : 'note',
});
if(countOfAttachment >= 1) {currentRecord.setValue('custbody_xxw_attachement', true)};
if(countOfNotes >= 1) {currentRecord.setValue('custbody_xxw_icn', true)};