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.
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)};