web
You’re offline. This is a read only version of the page.
close
Skip to main content
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,197

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,696 Moderator on at
    RE: Check mandatory value before posting payment journal

    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
    950 on at
    RE: Check mandatory value before posting payment journal

    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,197 on at
    RE: Check mandatory value before posting payment journal

    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,696 Moderator on at
    RE: Check mandatory value before posting payment journal

    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
    193 User Group Leader on at
    RE: Check mandatory value before posting payment journal

    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,529 on at
    RE: Check mandatory value before posting payment journal

    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

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

#1
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 3,401

#2
Sumit Singh Profile Picture

Sumit Singh 2,692

#3
YUN ZHU Profile Picture

YUN ZHU 1,935 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans