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