Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

can we run triggers multiple time?

(0) ShareShare
ReportReport
Posted on by 15

I want to run trigger multiple time using for loop inside data set of report can I do that? Please reply me I am hoping your help (I have added screen shot)  i have provided code also

code inside dataset of report

report 50136 "outstanding report details"
{
    UsageCategory = ReportsAndAnalysis;
    ApplicationArea = All;
    DefaultLayout = RDLC;
    RDLCLayout = 'outstandingreportdetails.rdl';

    dataset
    {
        dataitem(DataItemName; ExperimentTable)
        {

            column(CustomerId; "CustomerId")
            {

            }
            column(OutstandingBalance; "OutstandingBalance")
            {

            }
         
         for j := 1 to 4 do
                trigger OnAfterGetRecord()

                var
                    OutstandingBalaneList: List of [Decimal];
                    i: Integer;
                begin

                    OutstandingBalaneList.Add(5000.0);
                    OutstandingBalaneList.Add(6000.0);
                    OutstandingBalaneList.Add(7000.0);
                    OutstandingBalaneList.Add(8000.0);

                    for i := 1 to 4 do
                        if check = true then
                            if OutstandingBalance <> OutstandingBalaneList.Get(i) then
                                CurrReport.Skip();

                end;

        }

    }

    requestpage
    {
        layout
        {
            area(Content)
            {
                group(options)
                {
                    Caption = 'Options';
                    field("UserEnterdOutBal"; UserEnterdOutBal)
                    {
                        Caption = 'Amount LKR Greater than';
                        ApplicationArea = All;

                    }

                    field("check"; check)
                    {
                        Caption = 'Need to group';
                        ApplicationArea = All;

                    }
                }
            }
        }

        // actions
        // {
        //     area(processing)
        //     {
        //         action(ActionName)
        //         {
        //             ApplicationArea = All;

        //         }
        //     }
        // }
    }

    var
        UserEnterdOutBal: Decimal;
        check: Boolean;

        j : Integer;

    
}

  • Suggested answer
    Bilal Haider Profile Picture
    248 on at
    RE: can we run triggers multiple time?

    Hi,

    The error you are getting is because you are trying to take OnAfterGetRecord trigger inside a for loop. That is not possible. You cannot loop over this trigger simply. So this is answer.

    Next thing is that why you need to loop. The code inside OnAfterGetRecord will be run for every record of the table that you have mentioned. If you want to run certain piece of code multiple times for each record try to use for loop inside OnAfterGetRecord.

    Hopefully that make sense.

    Regards,

    Bilal Haider

  • Dhanajaya Perera Profile Picture
    15 on at
    RE: can we run triggers multiple time?

    if you can see my screen shot you will able to see there is a syntax error under for key word I need to know why? and I have written that code under report section, Thing which I want to do is, I need to run OnAfterGetRecord() trigger so that equal to list of length

  • JAngle Profile Picture
    95 on at
    RE: can we run triggers multiple time?

    You can yes. Check out this: docs.microsoft.com/.../devenv-al-control-statements

    Pay attention to the repeat until in the repetitive statements section. Each row of data from the original data set will be worked on regardless.

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

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

#1
Sohail Ahmed Profile Picture

Sohail Ahmed 732

#2
YUN ZHU Profile Picture

YUN ZHU 689 Super User 2025 Season 1

#3
Mansi Soni Profile Picture

Mansi Soni 529

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans