// Load the sales order
var record = nlapiLoadRecord('salesorder',291);
// Get the transaction date of the sales order.
var soDate = record.getFieldValue('trandate');
//Converts the string to date and returns the date object.
var tDate = nlapiStringToDate(soDate, 'datetz');
//Adds Months to that date. if you want to add years change the value from 6 to 12, 24, 36, etc
var nDate = nlapiAddMonths(tDate, 6);
//Convert the date object back to a String
var postDate = nlapiDateToString(nDate, 'datetz');
//Set the custom field with the date that you just created.
var field = record.setFieldValue('custbody2',postDate);
No comments:
Post a Comment