Netsuite LineItem的字段更改功能触发2次



我正在尝试存档以下内容

如果lineitem,"custcol_celigo_sfnc_line_id"字段与值" 01t0g00000bx4wday& quot;匹配,则添加日期。

在这里我面临的问题,这个记录是触发2次而不是一次。

/**
*@NApiVersion 2.x
*@NScriptType ClientScript
*/
define(['N/record', 'N/search', 'N/url', 'N/https', 'N/runtime'], function(record, search, url, https, runtime) {
function fieldChanged(context) {

var currentRecord = context.currentRecord;


var sublistName = context.sublistId;
var sublistFieldName = context.fieldId;
//  alert(JSON.stringify(currentRecord));
//alert(JSON.stringify(context));
var line = context.line;
var start_Date="custcol_atlas_contract_start_date";
var end_date="custcol_atlas_contract_end_date";
if (sublistName === 'item') {
if (sublistFieldName === 'custcol_celigo_sfnc_line_id')
{
var value = currentRecord.getCurrentSublistValue({
sublistId: sublistName,
fieldId: sublistFieldName
})
if(value!="01t0g00000bx4WDAAY"||value!="01t70000004b5TWAAY"||value!="01t70000004b6LZAAY"||value!="01t0g00000Z9ryHAAR"||value!="01t0g00000Z9ryCAAR"||value!="01t0g00000aYySFAA0"||value!="01t0g00000aZJyRAAW")
{

if(value=="01t0g00000bx4WDAAY")
{
//  alert("Triggered");
var stdate = currentRecord.getCurrentSublistValue({
sublistId: sublistName,
fieldId: start_Date
})

var newDate = new Date(stdate.setMonth(stdate.getMonth()+1));

currentRecord.setCurrentSublistValue({
sublistId: sublistName,
fieldId: start_Date,
value: newDate
});
}





}

}
}
return true;
}
var exports = {};

exports.fieldChanged = fieldChanged;
return exports;
});

这个脚本触发了2次,所以它添加了double。如何让它触发一次?

Thanks in advance

我不认为脚本可以触发两次。你收到"触发"警告两次?

/**
*@NApiVersion 2.x
*@NScriptType ClientScript
*/
define(['N/record', 'N/search', 'N/url', 'N/https', 'N/runtime'], function(record, search, url, https, runtime) {
function fieldChanged(context) {

var currentRecord = context.currentRecord;


var sublistName = context.sublistId;
var sublistFieldName = context.fieldId;
//  alert(JSON.stringify(currentRecord));
//alert(JSON.stringify(context));
var line = context.line;
var start_Date="custcol_atlas_contract_start_date";
var end_date="custcol_atlas_contract_end_date";
if (sublistName === 'item') {
if (sublistFieldName === 'custcol_celigo_sfnc_line_id')
{
var value = currentRecord.getCurrentSublistValue({
sublistId: sublistName,
fieldId: sublistFieldName
})
if(value!="01t0g00000bx4WDAAY"||value!="01t70000004b5TWAAY"||value!="01t70000004b6LZAAY"||value!="01t0g00000Z9ryHAAR"||value!="01t0g00000Z9ryCAAR"||value!="01t0g00000aYySFAA0"||value!="01t0g00000aZJyRAAW")
{

if(value=="01t0g00000bx4WDAAY")
{
//  alert("Triggered");
var stdate = currentRecord.getCurrentSublistValue({
sublistId: sublistName,
fieldId: start_Date
})

var newDate = new Date(stdate.setMonth(stdate.getMonth()));

currentRecord.setCurrentSublistValue({
sublistId: sublistName,
fieldId: start_Date,
value: newDate
});
}





}

}
}
return true;
}
var exports = {};

exports.fieldChanged = fieldChanged;
return exports;
});

尝试上面的代码一次。请在下面的评论中告诉我最新的消息。

最新更新