0

i m trying to populate a custom field with the value of the corresponding trandate(2 months ahead) e.g if the trandate is 13/05/2019 then the custom field should be 13/07/2019. I am using nlapiAddMoths() in my client script(field changed function) but receiving error. Can anyone help me with this?

function fieldchanged(type,name)//in netsuite, function will be field changed
{
    if (name=='trandate')
    {
        var newdate = nlapiAddMonths(trandate, 2)
        nlapiSetFieldValue('custbody_eta_date_test',newdate,true);//custbody_eta_date_test is my custom field where i want the incremented date to be populated
    }
}
4N335
  • 267
  • 2
  • 29

1 Answers1

2

For one thing you are using the field name instead of the field value. Try:

var newdate = nlapiAddMonths(nlapiStringToDate(nlapiGetFieldValue('trandate')), 2)
bknights
  • 14,408
  • 2
  • 18
  • 31