Skip to main content

Notifications

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

[Newbie] setting Max value for standard dialogue field from extended general ledge setup

Posted on by 60

Greetings,

I would like to take an input from the user which is a year and i want the max accepted value to be taken from the general ledger setup table.

I added the maximum integer field in the general ledger table field:

field(50102; MaxYearForCommissions; Integer)
        {
            Caption = 'Max Year For Commissions';
            DataClassification = ToBeClassified;
        }
 

and then proceeded by creating a field in the standard dialogue page where i want this integer to be added:

field(SelectedYear; SelectedYear)
            {
                ApplicationArea = All;
                Caption = 'SelectedYear';
                //add max value here
            }

Things I tried:

GenLedgSetup: Record "General Ledger Setup";
        MinimumValue: integer;
        MaximumValue: integer;

    trigger OnOpenPage()
    begin
        System.Clear(SelectedYear);
        // MaximumValue := GenLedgSetup.MaxYearForCommissions; (BC is crashing when running this code)
    end;

  • Charbel Hleyhel Profile Picture
    Charbel Hleyhel 60 on at
    RE: [Newbie] setting Max value for standard dialogue field from extended general ledge setup

    Thank you for your answer!

    Even though I thought about this but I thought there would be a more straight forward answer that I did not consider.

  • Verified answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,125 Super User 2024 Season 2 on at
    RE: [Newbie] setting Max value for standard dialogue field from extended general ledge setup

                       trigger OnValidate()

                       begin

                           GenLedgSetup.get();

                          If SelectedYear > GenLedgSetup.MaxYearForCommissions then

                            Error('You have selected beyond the allowed year.');

                       end;

  • Charbel Hleyhel Profile Picture
    Charbel Hleyhel 60 on at
    RE: [Newbie] setting Max value for standard dialogue field from extended general ledge setup

    Thank you for your answer but i think I misled you with my question.

    To rephrase it:

    I would like the user to populate the Selected Year field of the standard dialogue but I want to set a criteria where the max value the field can take is equal to the integer entered in the general ledger setup.

    Thank you!

    *edit:Grammar mistake.

  • Verified answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,125 Super User 2024 Season 2 on at
    RE: [Newbie] setting Max value for standard dialogue field from extended general ledge setup

    If I understood correct then you want to show the MaxYearForCommissions value of General Ledger Setup in the SelectedYear of the StandardDialogue page?

    If yes then

    trigger OnOpenPage()

       begin

           System.Clear(SelectedYear);

          GenLedgSetup.get();

          SelectedYear:= GenLedgSetup.MaxYearForCommissions;

       end;

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,151 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,963 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans