复制子列表字段中的先前值

Copy previous value in a sublist field

我正在尝试向销售订单记录上的项目子列表添加一个字段,该字段在更改时复制另一个字段的原始值。它几乎保留了另一个字段的先前值。每当我在客户端脚本中的 Validate 字段触发器中执行 nlapiGetCurrentLineItemValue 时,它​​都会给我新值(由用户更改),而不是更改前的值。有没有办法在客户端脚本中的 validatefield 事件中编辑字段之前获取字段的值?或者通过任何其他方式?

function validateFieldChanged(type, name, linenum) {
    if (type == 'item' && name == 'custcol_commit_date') {               
        nlapiSetCurrentLineItemValue('item', 'custcol_last_commit_date', nlapiGetCurrentLineItemValue('item', 'custcol_commit_date'), true,true);
    }
    return true;
}

我以前做过类似的事情。

在脚本的顶部,声明一个变量,例如 var existingValue;

然后在您的 lineInit 函数中,获取字段值并将其存储在 existingValue 中。

然后当您拥有 validateField 时,您将 be 值与 existingValue 进行比较。