Discussions
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 ---