web
You’re offline. This is a read only version of the page.
close
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;

    
}

I have the same question (0)
  • JAngle Profile Picture
    133 on at

    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.

  • Dhanajaya Perera Profile Picture
    15 on at

    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

  • Suggested answer
    Bilal Haider Profile Picture
    414 on at

    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

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,785

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,007 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 948 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans