web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

Check mandatory value before posting payment journal

(0) ShareShare
ReportReport
Posted on by 3,332

Hi All

I'm trying to make dimension code 2 field mandatory on payment journal. However though I have specified the journal template = payment, the validation is triggered on cash receipt and general journals. How do I isolate this check to the particular journal type (payment) ?

Here's my code so far:

    [EventSubscriber(ObjectType::Codeunit, codeunit::"Gen. Jnl.-Post Batch", 'OnBeforePostGenJnlLine', '', true, true)]

    local procedure CheckDim2Paymt(var GenJournalLine: Record "Gen. Journal Line")

    var

    begin

        GenJournalLine.Reset();

        GenJournalLine.SetRange("Journal Template Name", 'PAYMENT');

  

        GenJournalLine.SetFilter(Amount, '<>%1', 0);

        GenJournalLine.SetRange("Shortcut Dimension 2 Code", '');

        if GenJournalLine.FindFirst() then

 

                error('check dim2');

I have the same question (0)
  • Suggested answer
    Nitin Verma Profile Picture
    21,812 Moderator on at

    Hi Samantha73 ,

    If you are using any account type you can go Dimension from that Account type card and put the Dimension as Mandatory like the below image showing Mandatory for GL account No. in this case. by doing this system will not allow you post the entry until you provide the dimension. and Choose "Code mandatory" 

    pastedimage1656501999775v1.png

  • Suggested answer
    divyeshchitte Profile Picture
    970 on at

    One additional Information to Nitin Verma Comment

    When you make the Code Mandatory on the default Dimension, It will not allow you to post any transaction apart from Payment journal Like Sales Order , Sales Invoice , Purchase Orders and Invoice.

  • Samantha73 Profile Picture
    3,332 on at

    Thanks for the replies but dimension is an example so what I want is how to set a field mandatory only on a particular type of journal (General/Payment) etc with a bunch of other conditions so the solution is extendable

  • Suggested answer
    Nitin Verma Profile Picture
    21,812 Moderator on at

    Please give a try below

       [EventSubscriber(ObjectType::Codeunit, codeunit::"Gen. Jnl.-Post Batch", 'OnBeforePostGenJnlLine', '', true, true)]

       local procedure CheckDim2Paymt(var GenJournalLine: Record "Gen. Journal Line")

       var

           GenJournalLine2: Record "Gen. Journal Line";

       begin

           GenJournalLine2.Reset();

           GenJournalLine2.SetRange("Journal Template Name",GenJournalLine."Journal Template Name");

           GenJournalLine2.SetRange("Journal Batch Name",GenJournalLine."Journal Batch Name");

           GenJournalLine2.SetFilter(Amount, '<>%1', 0);

           GenJournalLine2.SetRange("Shortcut Dimension 2 Code", '');

           if GenJournalLine2.FindFirst() then

               error('check dim2');

       end;

    }

  • Suggested answer
    Dallefeld Profile Picture
    235 User Group Leader on at

    Dimensions requirements on based on master records such as the Bank Account and controlled absolutely at the GL Account record. No code should be required.

  • Suggested answer
    MahGah Profile Picture
    15,613 on at

    Maybe use the following free app which is more flexible.

    appsource.microsoft.com/.../PUBID.navtilus|AID.9762768c-307f-4b98-9b08-7abbaea78671|PAPPID.9762768c-307f-4b98-9b08-7abbaea78671

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 677 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 521 Super User 2026 Season 1

#3
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 306 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans