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 has launched SuiteSuccess Wholesale Distribution Edition, in Japan. Please join us the webinar on February 12 that introduces NetSuite solution with demos and case studies for Wholesale Industry.
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 ---