Skip to main content

Notifications

Small and medium business | Business Central, N...
Answered

Adding a Custom field to Payment Journal that can post to Vendor Ledger Entry

Posted on by 53
Good Day Experts,

I am trying to get the data of my new custom field /APTRRC_PayJourNo/ on table Gen. Journal Line to reflect on Vendor Ledger Entries when posted.

What I have done so far is:

* Created the new field /APTRRC_PayJourNo/ on Table /Gen. Journal Line/
* Created the new field /APTRRC_PayJourNo/ on Table /Vendor Ledger Entry/
* Created an EventSubscriber that should carry the data over to the Vendor Ledger Entry table.

Currently this is not working, please see below my EventSubscriber: (I am not sure if i am using the correct event or if this code will work there are 264 events triggered when the post button is clicked)
 
    [EventSubscriber(ObjectType::Codeunit, Codeunit::/Gen. Jnl.-Post Line/, 'OnAfterInitVendLedgEntry', '', false, false)]
    local procedure PayJourNo(VendorLedgerEntry: Record /Vendor Ledger Entry/; GenJournalLine: Record /Gen. Journal Line/)
    begin
        VendorLedgerEntry.APTRRC_PayJourNo := GenJournalLine.APTRRC_PayJourNo;
        Message('Event Triggered, %1, %2', GenJournalLine.APTRRC_PayJourNo, VendorLedgerEntry.APTRRC_PayJourNo);
    end;

In my message box I do get the correct values to show when I click the post button but when I navigate to Vendor Ledger Entries my value remains blank.

Can you please assist me where I am going wrong?

Thanks
 
  • Divan Profile Picture
    Divan 53 on at
    Adding a Custom field to Payment Journal that can post to Vendor Ledger Entry
    Thanks guys

    Both these answers work 100%, looks like I have used the wrong EventSubscriber
  • Verified answer
    Shrey Chauhan Profile Picture
    Shrey Chauhan 288 on at
    Adding a Custom field to Payment Journal that can post to Vendor Ledger Entry
    Hello,

    You use this following code for your reference and queries:
     
    tableextension 50002 GenJournalLineTab extends "Gen. Journal Line"
    {
        fields
        {
            field(50001; "APTRRC PayJourNo."; Code[20])
            {
                Caption = 'APTRRC PayJourNo.';
                DataClassification = CustomerContent;
            }
        }
    }
    pageextension 50002 PaymentJournalCard extends "Payment Journal"
    {
        layout
        {
            addafter("Account No.")
            {
                field("APTRRC PayJourNo."; Rec."APTRRC PayJourNo.")
                {
                    ApplicationArea = All;
                    Caption = 'APTRRC PayJourNo.';
                }
            }
        }
    }
    tableextension 50003 VendorLedgerEntryTab extends "Vendor Ledger Entry"
    {
        fields
        {
            field(50001; "APTRRC PayJourNo."; Code[20])
            {
                Caption = 'APTRRC PayJourNo.';
                DataClassification = CustomerContent;
            }
        }
    }
    pageextension 50003 VendorLedgerEntry extends "Vendor Ledger Entries"
    {
        layout
        {
            addafter("Document No.")
            {
                field("APTRRC PayJourNo."; Rec."APTRRC PayJourNo.")
                {
                    ApplicationArea = All;
                    Caption = 'APTRRC PayJourNo.';
                }
            }
        }
    }
    codeunit 50003 EventSubCodeunit
    {
        [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("APTRRC PayJourNo.", GenJournalLine."APTRRC PayJourNo.");
        end;
    }

    Hope this helps,

    Thank you.
  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 73,296 Super User 2024 Season 2 on at
    Adding a Custom field to Payment Journal that can post to Vendor Ledger Entry
    Hi, please try the following.
    tableextension 50112 MyExtension extends "Gen. Journal Line"
    {
        fields
        {
            field(50100; "My Field"; Text[30])
            {
                Caption = 'My Field';
                DataClassification = CustomerContent;
            }
        }
    }
    
    pageextension 50111 MyExtension extends "Payment Journal"
    {
        layout
        {
            addafter(Description)
            {
                field("My Field"; Rec."My Field")
                {
                    ApplicationArea = All;
                    Caption = 'My Field';
                }
            }
        }
    }
    
    tableextension 50113 MyExtension2 extends "Vendor Ledger Entry"
    {
        fields
        {
            field(50100; "My Field"; Text[30])
            {
                Caption = 'My Field';
                DataClassification = CustomerContent;
            }
        }
    }
    
    pageextension 50113 MyExtension2 extends "Vendor Ledger Entries"
    {
        layout
        {
            addafter(Description)
            {
                field("My Field"; Rec."My Field")
                {
                    ApplicationArea = All;
                    Caption = 'My Field';
                }
            }
        }
    }
    
    codeunit 50113 MyCodeunit2
    {
        [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("My Field", GenJournalLine."My Field");
        end;
    }
     
    Test:
     
    Hope this helps.
    Thanks.
    ZHU

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,188 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,030 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans