NetSuite / Suitescript - 为什么此Validate Field脚本会进入无限循环?

时间:2017-04-07 03:10:32

标签: validation field netsuite suitescript

我的脚本进入无限循环,我不知道为什么。我在验证字段上运行此操作,如果存在具有相同参考编号的其他供应商帐单,我阻止更改字段,从而强制用户更改"参考编号"独一无二。这是我的代码:

function validateField(type, name) {

    if (uniqueReferenceNum(type, name) === false) {

        return false;
    }

return true;
}


function uniqueReferenceNum(type, name) {

if (name !== 'tranid') {

    return true;
}

var tranID = nlapiGetFieldValue('tranid');
var vendor = nlapiGetFieldValue('entity');
var vendorName = nlapiGetFieldText('entity');

var filters = new Array();
var columns = new Array();

filters[0] = new nlobjSearchFilter('entity', null, 'is', vendor);
filters[1] = new nlobjSearchFilter('tranid', null, 'is', tranID);
filters[2] = new nlobjSearchFilter('mainline', null, 'is', 'T');

columns[0] = new nlobjSearchColumn('internalid');

results = nlapiSearchRecord('vendorbill', null, filters, columns);

if (!results) {

    return true;

}


alert("There is already a vendor bill with reference # " + tranID + " for " + vendorName + ". Please verify and change the reference number before continuing.");
return false;
}

0 个答案:

没有答案