如何在交易后 2 个月使用 nlapiAddMonths 设置字段值? (在客户端脚本中)

How to use nlapiAddMonths to set a field value 2 month after a trandate? (in client script)

我正在尝试用相应的 trandate(提前 2 个月)的值填充自定义字段,例如,如果 trandate 是 13/05/2019,那么自定义字段应该是 13/07/2019。我在我的客户端脚本(字段更改函数)中使用 nlapiAddMoths() 但收到错误。谁能帮我解决这个问题?

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

一方面,您使用的是字段名称而不是字段值。尝试:

var newdate = nlapiAddMonths(nlapiStringToDate(nlapiGetFieldValue('trandate')), 2)