Reputation: 95
I am trying to create Inventory Receipt of 2 step transfer, from screen when we select the Transfer # all the fields will be populated, same way when i tried to pass the transfer number from code no fields are getting populated, blank document is creating, can some one help me on this. please have a look at below code
INReceiptEntry intrgraph = PXGraph.CreateInstance<INReceiptEntry>();
INRegister objRegister = new INRegister();
objRegister.DocType = INDocType.Receipt;
objRegister = intrgraph.receipt.Insert(objRegister);
intrgraph.Save.Press();
INRegister objRegisteru = intrgraph.receipt.Current;
objRegisteru.TransferNbr = "000578";
objRegisteru = intrgraph.receipt.Update(objRegisteru);
intrgraph.Save.Press();
Upvotes: 0
Views: 169
Reputation: 8278
This example creates a transfer document with detail line and allocation. You can substitute the Transfer
part with Receipt
, it uses nearly identical patterns:
INTransferEntry transferEntry = PXGraph.CreateInstance<INTransferEntry>();
// Document Header
INRegister register = transferEntry.CurrentDocument.Insert();
register.DocType = INDocType.Transfer;
register.SiteID = [???];
register.ToSiteID = [???];
register.BranchID = Accessinfo.BranchID;
register.TranDesc = "Description";
register.TotalQty = 1M;
// Transactions Detail line
INTran inTran = new INTran();
inTran.DocType = INDocType.Transfer;
inTran.RefNbr = register.RefNbr;
inTran = transferEntry.transactions.Insert(inTran);
inTran.BranchID = Accessinfo.BranchID;
inTran.LocationID = [???];
inTran.ToLocationID = [???];
inTran.InventoryID = inventoryItem.InventoryID;
inTran.TranDesc = inventoryItem.Descr;
inTran.TranType = INTranType.Transfer;
inTran.UOM = inventoryItem.BaseUnit;
inTran.Qty = 1M;
// Lot/Serial number allocations
INTranSplit tranSplit = transferEntry.splits.Insert();
tranSplit.Qty = 1M;
tranSplit.LocationID = [???];
tranSplit.LotSerialNbr = [???];
tranSplit.UOM = inventoryItem.BaseUnit;
transferEntry.splits.Update(tranSplit);
transferEntry.Actions.PressSave();
To populate the details lines of the Receipt
from the Transfer
you need to invoke the event handler of INRegister.TransferNbr
field. This can be done with SetValueExt
method which raises FieldUpdated
events:
graphINReceiptEntry.transactions.Cache.SetValueExt<INRegister.transferNbr>(register, transferNbr)
When setting the TransferNbr
with SetValueExt
it will invoke the INRegister_TransferNbr_FieldUpdated
event handler of INReceiptEntry
graph which insert the details lines from the transfer in the receipt.
Upvotes: 1