validation - NetSuite / Suitescript - Why does this Validate Field script enter an infinite loop? -
my script entering infinite loop , have no idea why. running on validate field , preventing change field if vendor bill exists same reference number, forcing user change "reference number" unique. here 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 vendor bill reference # " + tranid + " " + vendorname + ". please verify , change reference number before continuing."); return false; }
Comments
Post a Comment