Hello,
I am attempting to create an inventorycount record using SuiteScript 1.0, I am running into an error on the "nlapiSubmitRecord" statement, the script is throwing an error message "This Item requires a Bin To Be Selected" when I do the nlapiSubmitRecord In my script I am setting the "Bin Location" correctly.
The set of data that I am using is valid, I am able to create an inventorycount record using SuiteScript 2.0. Unfortunately, I can't use SuiteScript 2.0 for this project.
Below is the SuiteScript 1.0 that I am using for my testing
function myCreateInventoryCount(inventorycountarray)
{ // START myCreateInventoryCount
try
{
nlapiLogExecution('DEBUG', 'myCreateInventoryCount', 'Start' );
var returnToSender = true;
// INVENTORY_COUNT
var myRecType = 'inventorycount';
var memo = 'Created Via CreateInventoryCount Script';
var linememo = 'linememo-Created Via CreateInventoryCount Script';
var itemId = null;
var binNumberId = null;
// just want to process thru this method, DO NOT want to actually create the inventory count record
var bTest = false;
var bSetHeader = true;
// set the array
var inventoryCountItems = inventorycountarray;
var memo = 'Created Via CreateInventoryCount Script';
var linememo = 'linememo-Created Via CreateInventoryCount Script';
var inventoryCountItems = inventorycountarray;
// inventoryCountItems[arrarylenth] = [currentItem, currentBinNumber, currentBinlocation,subsidiaryInternalId]
recCnt = inventoryCountItems.length;
nlapiLogExecution('DEBUG','myCreateInventoryCount', 'INVENTORY_COUNT Records to be created = ' + recCnt);
var inventoryCount = nlapiCreateRecord('inventorycount' ,{ recordmode: 'dynamic'} );
for (var i = 0; i < inventoryCountItems.length; i++)
{
// get the size of the inner array
var innerArrayLength = inventoryCountItems[i].length;
// loop the inner array
// get the itemId and the binNumber
itemId = inventoryCountItems[i][0]
binNumberId = inventoryCountItems[i][1]
binLocationId = inventoryCountItems[i][2]
subsidiaryInternalId = inventoryCountItems[i][3]
nlapiLogExecution( 'DEBUG', 'myCreateInventoryCount','itemId = ' + itemId + ' binNumberId = ' + binNumberId + ' binLocationId = ' + binLocationId + ' subsidiaryInternalId = ' + subsidiaryInternalId );
// load the header properties
if (bSetHeader)
{
inventoryCount.setFieldValue('subsidiary',subsidiaryInternalId );
inventoryCount.setFieldValue('location', binLocationId);
inventoryCount.setFieldValue('memo', memo);
bSetHeader = false;
}
inventoryCount.selectNewLineItem('item');
inventoryCount.setCurrentLineItemValue('item', 'item', itemId);
inventoryCount.setCurrentLineItemValue('item', 'binNumber', binNumber);
// inventoryCount.commit();
inventoryCount.commitLineItem('item');
}
// save the record
recordId = nlapiSubmitRecord(inventoryCount,true);
nlapiLogExecution('DEBUG','myCreateInventoryCount', 'INVENTORY_COUNT Record created = ' + recordId);
nlapiLogExecution('DEBUG', 'myCreateInventoryCount', 'End' );
} catch (e)
{
nlapiLogExecution('DEBUG', 'in Catch for myCreateInventoryCount', 'Error : ' + e);
returnToSender = false
}
// return the internalID of the subsidiary to the calling function
return returnToSender
} // END myCreateInventoryCount
var bTestCreateInventoryCount = true
var inventorycountarray = []
//var subsidiaryId = '1'; //
var subsidiaryId = '4'; //
var locationId = '3'; //
var myInventoryNumberItem = '3763' // Serialized Assembly/Bill of Materials 903-00037
// var binNumber = '25'; // FG-ROOM
var binNumber = '24'; // FG-FLOOR internalid = 24
inventorycountarray[0] = [myInventoryNumberItem,binNumber,locationId,subsidiaryId]
if (bTestCreateInventoryCount)
{
var stop = true
// myCreateInventoryCount(inventorycountarray)
recId = myCreateInventoryCount(inventorycountarray)
}
var stop = true