Flow Custom field to G/L Entry and other Posted tables : From Purchase Order to Posted Purchase invoice
Hi Readers,
In this blog we will see how we can transfer data from "Purchase Header" to "Purchase Invoice Header" & "G/L Entry" table in Business Central.
In this example, will create "Remarks" field on Purchase Header table and after posting, flow it to Purchase Invoice Header & G/L Entry tables:
Firsly, create required fields ("Remarks") in below mentioned tables by creating table extensions:
- Purchase Header (38)
- Purch. Inv. Header (122)
- Gen. Journal Line (81)
- G/L Entry (17)
For the Purch. Inv. Header table, you can just create copy the field from purchase header and paste it in Purch. Inv. Header table. If the field ID No. is same for that field for both the tables then you don't have to code i.e, it automatically transfer that field data from Purch. Header to Purch. Inv. Header.
Step-(1)
tableextension 50104 "Purchase Header Ext" extends "Purchase Header"
{
fields
{
field(50000; "Remarks"; Text[100])
{
DataClassification = ToBeClassified;
}
}
}
Step-(2)
tableextension 50103 "Purchase Inv Header Ext" extends "Purch. Inv. Header"
{
fields
{
field(50000; Remarks; Text[100])
{
DataClassification = ToBeClassified;
}
}
}
Step-(3)
tableextension 50102 "Gen. Journal Line Exn" extends "Gen. Journal Line"
{
fields
{
field(50000; "Remarks"; Text[100])
{
DataClassification = ToBeClassified;
}
}
}
Step-(4)
tableextension 50105 "General Ledger Entry Ext" extends "G/L Entry"
{
fields
{
field(50000; Remarks; Text[100])
{
DataClassification = ToBeClassified;
}
}
}
Step-(5) Now for flowing "Remarks" fields data to G/L Entry, we have to first transfer that field data to Gen. Journal Line table based on required condition by using Event subscriber in Table Gen. Journal Line (81) .
Then from that we can transfer it to G/L Entry. By using other Event Subscriber mentioned in CodeUnit "Gen. Jnl.-Post Line" - (12).
codeunit 50100 "Event Subscriber BackOffice"
{
trigger OnRun()
begin
end;
[EventSubscriber(ObjectType::Table, DataBase::"Gen. Journal Line",
'OnAfterCopyGenJnlLineFromPurchHeader', '', false, false)]
Procedure OnAfterCopyGenJnlLineFromPurchHeader(PurchaseHeader:
Record "Purchase Header"; Var GenJournalLine: Record "Gen. Journal Line")
begin
GenJournalLine.Remarks := PurchaseHeader.Remarks;
end;
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Gen. Jnl.-Post Line",
'OnAfterInitGLEntry', '', false, false)]
Procedure OnAfterInitGLEntry(var GLEntry: Record "G/L Entry"; GenJournalLine:
Record "Gen. Journal Line")
begin
GLEntry.Remarks := GenJournalLine.Remarks;
end;
}
Step-(6) Now add that field on Pages to Check wheather it's flowing or not:
- Purchase Order (50)
pageextension 50103 "Purchase Order Ext" extends "Purchase Order"
{
layout
{
addlast(General)
{
field(Remarks; Remarks)
{
ApplicationArea = All;
}
}
}
}
- Posted Purchase Invoice (138)
pageextension 50104 "Purchase Invoice Ext" extends "Posted Purchase Invoice"
{
layout
{
addlast(General)
{
field(Remarks; Remarks)
{
ApplicationArea = All;
}
}
}
}
- General Ledger Entries (20)
pageextension 50105 "GL Entry Ext" extends "General Ledger Entries"
{
layout
{
addafter(Description)
{
field(Remarks; Remarks)
{
ApplicationArea = All;
}
}
}
}
Output-
I hope it helps!! Thanks for Reading!!!
Your valuable comment & feedback is Highly appreciated.
Hello Kunal
ReplyDeleteFrom Purchase Line to G/L Entry
How Suggestion
yes
Deletei have made a custom field in sales line flow it in gl entry i am not getting the proper information how to flow it can you help in this
ReplyDelete