# Creating Part Lot record with quantity from code **Category:** [Epicor ERP 10](https://www.epiusers.help/c/e10/5) **Created:** 2016-12-30 21:36 UTC **Views:** 4424 **Replies:** 18 **URL:** https://www.epiusers.help/t/creating-part-lot-record-with-quantity-from-code/36748 --- ## Post #1 by @Aaron_Moreng Having a bit of frustration with creating a part lot record from form code. I'm creating Part Lot records on the fly to create user testing data. I'm attempting doing it by following the same methods that fire from a quantity adjustment transaction, but I keep failing at the end when I try to call the SetInventoryQtyAdj method from the Inventory Quantity Adjustment adapter. Here's what I've tried: string errorLocation = String.Empty; for(int i = 0; i Erp.Proxy.BO.InventoryQtyAdjImpl GetInventoryQtyAdj net.tcp://epicor10/Epicor10.1Coding/ Erp.Tablesets.InventoryQtyAdjTableset 1/3/2017 13:05:36:8946155 PM 0 Erp.Proxy.BO.InventoryQtyAdjImpl GetInventoryQtyAdjBrw net.tcp://epicor10/Epicor10.1Coding/ Erp.Tablesets.InventoryQtyAdjBrwTableset 1/3/2017 13:05:37:3365861 PM 0 ``` --- ## Post #5 by @Aaron_Moreng Thanks Jose, I was basically following the trace from an inventory qty adjustment transaction, but I did not see those methods until much later in the transaction. I will try calling those methods, thank you for your help! --- ## Post #6 by @Aaron_Moreng After calling those methods to get a data set, I still get no row at position 0. Do I need to create the row myself? --- ## Post #7 by @josecgomez not but you need to make sure you re using that dataset... share your code --- ## Post #8 by @Aaron_Moreng if(adapterLSA.GetByID(partNum,lotNum)){ //set the inventory quantity InventoryQtyAdjAdapter adapterQtyAdj = new InventoryQtyAdjAdapter(oTrans); adapterQtyAdj.BOConnect(); //call Get Inv Qty Adj adapterQtyAdj.GetInventoryQtyAdj(partNum, ""); InventoryQtyAdjDataSet qtyAdjData = adapterQtyAdj.InventoryQtyAdjData; //call GetInvQtyAdjBrw string primaryBin; adapterQtyAdj.GetInventoryQtyAdjBrw(partNum, "52", out primaryBin); InventoryQtyAdjBrwDataSet qtyAdjDataBrw = adapterQtyAdj.InventoryQtyAdjBrw; errorLocation = "259"; //Neg inv test string pcMessage; string pcNeqQtyAction; adapterQtyAdj.NegativeInventoryTest(partNum, "52", "receipt", lotNumRand,"", "EA", 1, -1, out pcNeqQtyAction, out pcMessage); //Pre Set Inv Qty Adj row and method InventoryQtyAdjDataSet.InventoryQtyAdjRow qaRow = (InventoryQtyAdjDataSet.InventoryQtyAdjRow)qtyAdjData.InventoryQtyAdj[0]; //this row doesn't exist //InventoryQtyAdjDataSet.InventoryQtyAdjRow qaRow = (InventoryQtyAdjDataSet.InventoryQtyAdjRow)qtyAdjData.InventoryQtyAdj.NewInventoryQtyAdjRow(); errorLocation = "267"; qaRow.BinNum = "receipt"; qaRow.AdjustQuantity = 1; qaRow.ReasonCode = "DJ002"; qaRow.LotNum = lotNumRand; qaRow.ReasonCodeDescription = "Accounting Adjust Disposition"; qaRow.WhseBinDescription = "Receipt Denver"; qaRow.RowMod = "U"; adapterQtyAdj.Update(); errorLocation = "275"; //preset inv qty adj method bool requiresUserInput; adapterQtyAdj.PreSetInventoryQtyAdj(out requiresUserInput); //CheckForNeedLotAttrs bool needsLotAttrs; adapterLSA.ChkForNeedsLotAttrs(partNum, lotNumRand, out needsLotAttrs); //Set Inv Qty Adj, no attributes called. errorLocation = "280"; string partTranPKs; adapterQtyAdj.SetInventoryQtyAdj(qtyAdjData,out partTranPKs); //cleanup adapter adapterQtyAdj.Dispose(); } --- ## Post #9 by @josecgomez Are you actually getting a Row when you run your Get? --- ## Post #10 by @Aaron_Moreng Good call, I am not. I just tested this > //call Get Inv Qty Adj > adapterQtyAdj.GetInventoryQtyAdj(partNum, ""); > InventoryQtyAdjDataSet qtyAdjData = adapterQtyAdj.InventoryQtyAdjData; > MessageBox.Show(qtyAdjData.Tables[0].Rows.Count.ToString()); I get a count of 0... --- ## Post #11 by @josecgomez Hmm dumb question is there inventory already in the system? --- ## Post #12 by @Aaron_Moreng It does not. Before I call this code block, I am (I think) creating the lot shell. I intended to create the actual inventory with this quantity adjustment transaction though, just as I would if interacting through the quantity adjustment form. for(int i = 0; i I'd really like to make sure I understand why my approach wasn't working and why yours does for this scenario. Thanks!! --- ## Post #15 by @josecgomez I think the function you were using GetInventoryQtyAdj returns a dataset vs the one I used GetInventoryQtyAdjustmentData merges the dataset into the adapter. That's likely the issue --- ## Post #16 by @Aaron_Moreng Always something new to learn, isn't there! :) thanks! --- ## Post #18 by @Chan213419 Same Exact error in Service Connect. Same exact methods called as Aaron did. Unfortunately, GetInventoryQtyAdjustmentData is not an available method to use in the InventoryQtyAdj adapter. If you guys have any ideas, i'd greatly appreciate it. --- ## Post #19 by @Aaron_Moreng Just an idea, but is there a way for you to hydrate a dataset without calling the GetInventoryQtyAdjusmentData method? Once that's filled out, there might be a way to call the code above (or a variation of) to accomplish the task. --- ## Post #20 by @Chan213419 Just figured it out. Thanks for the input. A silly mistake by me really. If anyone else runs into this while Building a Service Connect solution, you need to hardcode an A for the RowMod on the conversion going to the InventoryQtyAdj.PreSetInventoryQtyAdj Request. --- **Canonical:** https://www.epiusers.help/t/creating-part-lot-record-with-quantity-from-code/36748 **Original content:** https://www.epiusers.help/t/creating-part-lot-record-with-quantity-from-code/36748