Skip to main content

Notifications

Business Central forum
Answered

Transferring custom fields form Gen. Journal Line to General Ledger Entries, Custom Ledger Entries and Vendor Ledger Entries

Posted on by 241

Hi Experts,

I hope you all are doing well.

There is a custom field, Field Name "Narration" and Field Id 50000 in Table "Gen. Journal Line' (81). After posting a Gen Journal Line, values flow into different Ledger Entries depending upon the Account Type.  

In the case of sales invoices, when we define a new custom field in the sales header, we also define a new custom field with the same name. same data type and same id in the sales invoice header. And after posting a sales invoice that custom field automatically flows to the posted sales invoice. 

In BC 2021 Release Wave 2, I'm trying to post a General Journal but that new custom field is not flowing into respective ledger entries. For example, In Gen Journal Line the  "Account Type" is 'G/L Account' and "Bal Account Type" is also 'G/L Account' and after posting a General Journal, that new custom field doesn't automatically flow to General Ledger Entries. And similarly, that new custom field is not flowing to other ledger entries like customer ledger entries, vendor ledger entries, bank ledger entries, etc. 

This functionality is working fine in NAV 2017. but not working in BC 190. Can anyone please tell me how to resolve this issue,

Answers will be highly appreciated.

Thanks for reading.

Categories:
  • M Hussnain Javed Profile Picture
    M Hussnain Javed 241 on at
    RE: Transferring custom fields form Gen. Journal Line to General Ledger Entries, Custom Ledger Entries and Vendor Ledger Entries

    Thanks for replying.

    I got this idea before but I was not aware of where are the required integration events defined by Microsoft. With further R&D, I found those integration events written on the table level. And I would like to show the code to help others in the future.

    [EventSubscriber(ObjectType::Table, Database::"G/L Entry", 'OnAfterCopyGLEntryFromGenJnlLine', '', false, false)]

       local procedure OnAfterCopyGLEntryFromGenJnlLine(var GenJournalLine: Record "Gen. Journal Line"; var GLEntry: Record "G/L Entry")

       begin

           GLEntry.Validate(Narration, GenJournalLine.Narration);

       end;

       [EventSubscriber(ObjectType::Table, Database::"Vendor Ledger Entry", 'OnAfterCopyVendLedgerEntryFromGenJnlLine', '', false, false)]

       local procedure OnAfterCopyVendLedgerEntryFromGenJnlLine(GenJournalLine: Record "Gen. Journal Line"; var VendorLedgerEntry: Record "Vendor Ledger Entry")

       begin

           VendorLedgerEntry.Validate(Narration, GenJournalLine.Narration);

       end;

       [EventSubscriber(ObjectType::Table, Database::"Cust. Ledger Entry", 'OnAfterCopyCustLedgerEntryFromGenJnlLine', '', false, false)]

       local procedure OnAfterCopyCustLedgerEntryFromGenJnlLine(var CustLedgerEntry: Record "Cust. Ledger Entry"; GenJournalLine: Record "Gen. Journal Line")

       begin

           CustLedgerEntry.Validate(Narration, GenJournalLine.Narration);

       end;

       [EventSubscriber(ObjectType::Table, Database::"Bank Account Ledger Entry", 'OnAfterCopyFromGenJnlLine', '', false, false)]

       local procedure OnAfterCopyFromGenJnlLine(var BankAccountLedgerEntry: Record "Bank Account Ledger Entry"; GenJournalLine: Record "Gen. Journal Line")

       begin

           BankAccountLedgerEntry.Validate(Narration, GenJournalLine.Narration);

       end;

  • Verified answer
    YUN ZHU Profile Picture
    YUN ZHU 63,181 Super User on at
    RE: Transferring custom fields form Gen. Journal Line to General Ledger Entries, Custom Ledger Entries and Vendor Ledger Entries

    Hi, Some fields are not transferred automatically, so as Mohana mentioned, you need to investigate the event. Then you need to add Code as Subscription in Codeunit.

    More details: https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-subscribing-to-events

    Hope this helps as well.

    Thanks.

    ZHU

  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 32,718 Super User on at
    RE: Transferring custom fields form Gen. Journal Line to General Ledger Entries, Custom Ledger Entries and Vendor Ledger Entries

    Maybe you can also look into using an additional dimension instead of a custom field, then you will not have to do any customization to get the extra info to the ledgers.

  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 48,379 Super User on at
    RE: Transferring custom fields form Gen. Journal Line to General Ledger Entries, Custom Ledger Entries and Vendor Ledger Entries

    You have to use OnAfterInitGLEntry event of Codeunit "Gen. Jnl.-Post Line" to flow the fields

Helpful resources

Quick Links

Community Spotlight of the Month

Kudos to Mohamed Amine Mahmoudi!

Blog subscriptions now enabled!

Follow your favorite blogs

TechTalk: How Dataverse and Microsoft Fabric powers ...

Explore the latest advancements in data export and integration within ...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 285,356 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,435 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,146

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans