Monday, December 10, 2018

Add an Inventory Adjustment with Serialized Items using .NET

The following sample code shows how to add an Inventory Adjustment containing Serialized Items. Note that if the "Advanced Bin/Numbered Inventory Management" is not enabled, the serial/lot number data is available directly from the item.

public virtual void adjustInventory()
{
     InventoryAdjustment invAdjustment = new InventoryAdjustment();

     InventoryAdjustmentInventory[] invAdjustmentItemArray = new InventoryAdjustmentInventory[1];

     RecordRef item = new RecordRef();
     item.type = RecordType.inventoryItem;
     item.typeSpecified = true;
     item.internalId = "71";

     RecordRef loc = new RecordRef();
     loc.type = RecordType.location;
     loc.typeSpecified = true;
     loc.internalId = "1";
 

     invAdjustmentItemArray[0] = new InventoryAdjustmentInventory();
     invAdjustmentItemArray[0].item = item;
     invAdjustmentItemArray[0].adjustQtyBy = System.Double.Parse("1");
     invAdjustmentItemArray[0].adjustQtyBySpecified = true;
     invAdjustmentItemArray[0].location = loc;
     invAdjustmentItemArray[0].serialNumbers = "SRX1005";

     RecordRef account = new RecordRef();
     account.type = RecordType.account;
     account.typeSpecified = true;
     account.internalId = "64";

     InventoryAdjustmentInventoryList invList = new InventoryAdjustmentInventoryList();
     invList.inventory = invAdjustmentItemArray;
     invAdjustment.inventoryList = invList;
     invAdjustment.account = account;

     WriteResponse writeRes = _service.add(invAdjustment);

     if (writeRes.status.isSuccess)
     {
          _out.writeLn("\nAdjust Inventory successful");
     }
     else
     {
          _out.error(getStatusDetails(writeRes.status));
     }
}

No comments:

Post a Comment