I am new to scripting for netsuite and have the following issue. I am trying to write a script that runs when the user submits a Bill, that should validate if our Class field has a value on each line, returning true if every line has a value, or false as soon as it hits a line that is blank. The script seems to run without error, but does not actually stop the Bill from being posted if I have the field blank. Any helpful tips or ideas would be greatly appreciated!
function saveRecord()
{
// Check to see that Class is populated. If not, block the save and warn with a popup.
for (var i = 1; i <= nlapiGetLineItemCount('expense'); i++) {
if (String(nlapiGetLineItemField('expense','class',i)).length == 0)
{
alert("Please provide a value for Class");
return false;
}
}
return true;
}