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
Add Months to a Date Field Using SuiteScript
Referring to SuiteAnswers ID #30950, the solution provided does not work.
Production Date is a Custom Transaction Line Field of type Date.
Shelf Life is an Integer field.
--- BEGIN CODE ---
var prodDate = currentRecord.getCurrentSublistValue({
sublistId: sublistName,
fieldId: 'custcol_prod_date'
});
log.audit({
title: 'Production Date',
details: prodDate
});
var shelfLife = currentRecord.getCurrentSublistValue({
sublistId: sublistName,
fieldId: 'custcol_item_shelf_life'
});
log.audit({
title: 'Shelf Life',
details: shelfLife
});
var nProdDate = format.parse({
value: prodDate,
type: format.Type.DATETIMETZ
});
log.audit({
title: 'Formatted Production Date',
details: nProdDate
});
var expDate = nProdDate.setMonth(nProdDate.getMonth() + shelfLife);
log.audit({
title: 'Expiration Date',
details: expDate
});
--- END CODE ---