update custom fields in vendInvoiceInfoTable from PurchTable while invoicing the purchase order in D365FO. While invoicing the purchase order system will create a pending vendor invoice.
I have added a few custom fields in the purchase order header and purchase order line. So, I need to transfer the data from PurchTable to vendInvoiceInfoTable.
Check the below code.
For line fields:
[ExtensionOf(classStr(PurchFormletterParmData))] internal final class PurchFormLetterParmData_Extension { protected void createParmLineRecord(VendDocumentLineMap purchParmLine, PurchLine purchLine, VendDocumentLineAssetMap purchParmLine_Asset, TradeLineRefId tableRef, container quantities, container cwQuantities) { if (_purchParmLine.TableId == tableNum(VendInvoiceInfoLine)) { VendInvoiceInfoLine vendInvoiceInfoLine = _purchParmLine; vendInvoiceInfoLine.Field1 = _purchLine.Field1; vendInvoiceInfoLine.Field2 = _purchLine.Field2; } next createParmLineRecord(_purchParmLine, purchLine, purchParmLine_Asset, tableRef, quantities, _cwQuantities); } }
For Header and line fields:
[ExtensionOf(classStr(PurchFormletterParmDataInvoice))] final class VendInvoiceInfoLine_Extension { // Header fields update protected void createInvoiceHeaderFromTempTable() { vendInvoiceInfoTable vendInvoiceInfoTable; PurchTable purchtable; next createInvoiceHeaderFromTempTable(); select forupdate vendInvoiceInfoTable where vendInvoiceInfoTable.ParmId == this.parmId(); //&& vendInvoiceInfoTable.PurchId == purchtable.PurchId; purchtable = PurchTable::find(vendInvoiceInfoTable.PurchId); // Code ttsbegin; vendInvoiceInfoTable.Field2 = purchtable.Field2; vendInvoiceInfoTable.Field2 = purchtable.Field2; vendInvoiceInfoTable.update(); ttscommit; } // Line fields update protected void createParmLinesAndTable() { VendInvoiceInfoLine vendInvoiceInfoLine; PurchLine purchline; next createParmLinesAndTable(); while select forupdate vendInvoiceInfoLine where vendInvoiceInfoLine.ParmId == this.parmId() { purchline = PurchLine::findRecId(vendInvoiceInfoLine.PurchLineRecId); // Code ttsbegin; vendInvoiceInfoLine.Field1 = purchline.Field1; vendInvoiceInfoLine.Field2 = purchline.Field2; vendInvoiceInfoLine.update(); ttscommit; } } }
Keep Daxing!!
No comments:
Post a Comment