I have attempted to create a script that will fill in the lot number boxes on the fulfillment page. Or at least suggest which lot numbers they should be using. Right now I am at the point in this script of just pulling information from a saved search I have created. The issue is, I cannot seem to pull the data correctly as I keep getting null values. Can anyone give me a fresh look at this code and see where my errors might be?
function pageInit(type, name) { //first get list of itmes //then on each item search for what lost numbers and qty are avail //populate that field var lineNum = nlapiGetLineItemCount('item'); var counterOfLines = 1; while (counterOfLines <= lineNum) { var lineItem = nlapiGetLineItemValue('item','item',counterOfLines); var lineQty = nlapiGetLineItemValue('item','quantity',counterOfLines); //alert('The line item for this record is: ' + lineItem + ' on line ' + counterOfLines + ' with qty ' + lineQty); //now run a search for each line to grab a lot number var filters = new Array(); filters[0] = new nlobjSearchFilter('internalId', null, 'is', lineItem); //alert("Setting search results to " + lineItem); var searchresults = nlapiSearchRecord('item', "customsearch22", filters, null); alert ("search results are" + searchresults.length); var exp_column = new nlobjSearchColumn('expirationdate', 'inventoryAdjustment', null) //for the expiration date column if (searchresults != null) { for ( var i = 0; i < searchresults.length; i++ ) { var searchresult = searchresults[ i ]; //testing to find the column var columns = searchresult.getAllColumns(); var columnString = ""; /*for ( var j = 0; j < columns.length; j++) { columnString = columnString + ', ' + columns[j].getLabel()); }*/ //alert("column are " + columnString); var lot = searchresult.getValue('num'); var expire = searchresult.getValue('exp'); var expire2 = searchresult.getValue(exp_column); var internalID = searchresult.getValue('internalId'); alert("Number = " + lot + ' expire ' + expire + 'expire2 ' + expire2 + ' internal ID ' + internalID); } } counterOfLines++; } } This is an item type search with these result parameters and the right values are custom names of qty and exp assigned: Name Inventory Number : Available qty Inventory Number : Expiration Date exp Internal ID
Any ideas?