NetSuite / Suitescript - Why does this Validate Field script enter an infinite loop?

随声附和 提交于 2019-12-07 10:47:05

问题


My script is entering into an infinite loop and I have no idea why. I am running this on validate field and I am preventing a change to the field if another vendor bill exists with the same reference number, forcing the user to change the "Reference Number" to be unique. Here is my code:

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

来源:https://stackoverflow.com/questions/43268980/netsuite-suitescript-why-does-this-validate-field-script-enter-an-infinite-l

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!