I am trying to create a script to validate line items based on the selection of a custom field on a sales order record. So I need to script to run through each selection item and check to see if the items noted in the script have been added to the order. If so, I wish to present a message. If item is not on order then I wish to move on to the next if statement. During testing I am finding that both alerts are being displayed. What am I missing? Here is my script:
function validateLine_rec() {
var stRecord = nlapiGetRecordType();
var stProgram = nlapiGetFieldValue('custbody64');
if (stRecord == 'salesorder') {
if (stProgram == '2' || '11') {
var stItemId = nlapiGetCurrentLineItemValue('item', 'item');
if (stItemId == '24' || '25' || '26' || '27' || '28' || '49'
|| '50' || '51' || '52' || '59' || '61' || '65' || '71'
|| '72' || '73' || '74' || '152' || '153' || '154' || '155'
|| '157' || '158' || '159' || '160' || '217' || '248'
|| '249' || '268' || '269' || '271' || '315' || '320'
|| '321' || '349' || '350' || '355' || '356' || '360'
|| '361' || '362' || '398' || '470' || '471' || '472'
|| '513' || '514' || '516' || '517' || '518' || '519'
|| '20' || '37' || '79' || '184' || '324' || '474' || '478'
|| '482' || '500' || '38' || '80' || '132' || '185'
|| '325' || '327' || '370' || '390' || '414' || '416'
|| '420' || '421' || '436' || '440' || '453' || '455'
|| '456' || '461' || '464' || '465' || '468' || '469'
|| '475' || '477' || '484' || '487' || '501' || '502'
|| '503' || '504' || '550' || '21' || '40' || '81' || '187'
|| '191' || '192' || '224' || '323' || '326' || '393'
|| '394' || '397' || '402' || '423' || '427' || '429'
|| '438' || '442' || '476' || '505') {
alert('You can not use this item for Classbook Orders');
}
if (stProgram == '9') {
var stItemId = nlapiGetCurrentLineItemValue('item', 'item');
if (stItemId == '81' || '423' || '505' || '187' || '393'
|| '326' || '323' || '224' || '427' || '438' || '40'
|| '394' || '21' || '476' || '191' || '397' || '192'
|| '402' || '55' || '275' || '431' || '149' || '392'
|| '303' || '422' || '426' || '437' || '95' || '434'
|| '188' || '395' || '53' || '479' || '301' || '136'
|| '34' || '480' || '93' || '483' || '101' || '378'
|| '451' || '430' || '410' || '458' || '459' || '432'
|| '302' || '137' || '391' || '413' || '460' || '35'
|| '454' || '457' || '485' || '415' || '462' || '463'
|| '435' || '306' || '94' || '473' || '498' || '497'
|| '412' || '433' || '486' || '496' || '55' || '275'
|| '431' || '149' || '392' || '303' || '422' || '426'
|| '437' || '95' || '434' || '188' || '395' || '79'
|| '500' || '324' || '37' || '478' || '20' || '474'
|| '414' || '461' || '502' || '501' || '80' || '390'
|| '504' || '503' || '325' || '550' || '416' || '464'
|| '465' || '436' || '38' || '455' || '456' || '484'
|| '421' || '477' || '132' || '475' || '81' || '423'
|| '505' || '187' || '393' || '326' || '323' || '224'
|| '427' || '438' || '40' || '394' || '21' || '476'
|| '191' || '397' || '192' || '402' || '45' || '46'
|| '47' || '48' || '353' || '354' || '75' || '76'
|| '77' || '78' || '363' || '364' || '29' || '30'
|| '31' || '223' || '357' || '358' || '189' || '90'
|| '91' || '92' || '388' || '389' || '71' || '72'
|| '73' || '74' || '248' || '249' || '361' || '362'
|| '320' || '513' || '321' || '514' || '26' || '539'
|| '528' || '27' || '540' || '529' || '28' || '541'
|| '530' || '271' || '542' || '531' || '315' || '543'
|| '532' || '472' || '544' || '533' || '268' || '545'
|| '534' || '355' || '546' || '535' || '470' || '356'
|| '547' || '536' || '152' || '516' || '153' || '517'
|| '154' || '518' || '155' || '519' || '157' || '520'
|| '158' || '521' || '159' || '522' || '160' || '523'
|| '524' || '471' || '360' || '525' || '24' || '269'
|| '25' || '398') {
alert('You can not use this item for School-Wide: Traditional Orders');
return false;
}
}
return true;
}
}
}