如何在转换后2个月内使用nlapiAddMonths设置字段值? (以客户端脚本的形式)

时间:2019-07-13 07:27:32

标签: javascript netsuite suitescript clientscript

我试图用对应的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
    }
}

1 个答案:

答案 0 :(得分:2)

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

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