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

selected lines

(6) ShareShare
ReportReport
Posted on by 188
need to send an email only to the records that the user selects in a list page. What is the recommended way to capture the selected lines in a page so I can loop through them and pass the data (e.g., email addresses) into my mail-sending function?
I have the same question (0)
  • Verified answer
    Sahan Hasitha Profile Picture
    2,683 on at
    hi
    use CurrPage.SetSelectionFilter this and use loop
  • Verified answer
    Sumit Singh Profile Picture
    11,797 Super User 2026 Season 1 on at
    Hi,

    Use CurrPage.SetSelectionFilter on an action. It captures only the user‑selected rows into a record variable (same table), which you can loop and pass to your mail function.
    actions
    {
        action(SendEmails)
        {
            Caption = 'Send Emails';
            Image = Email;
            ApplicationArea = All;
            Promoted = true; PromotedCategory = Process;

            trigger OnAction()
            var
                Sel: Record "Customer"; // use your page's source table
            begin
                CurrPage.SetSelectionFilter(Sel);
                if Sel.IsEmpty() then
                    Error('Select at least one row.');

                if Sel.FindSet() then
                    repeat
                        if Sel."E-Mail" <> '' then
                            SendCustomerMail(Sel."No.", Sel."E-Mail"); // your function
                    until Sel.Next() = 0;
            end;
        }
    }
    Notes
    • Ensure the list page allows multi‑select (default is allowed on List pages).
    • If you want to process elsewhere, pass Sel (with its selection filter) or copy keys to a temp table/list.
    Response created with the help of Co-Pilot. Please mark “Verified” if it helps.
  • Verified answer
    Sahan Hasitha Profile Picture
    2,683 on at
    hi
     
    try this
  • Verified answer
    Rishabh Kanaskar Profile Picture
    6,231 Super User 2026 Season 1 on at
    Hi,
     
    Use the built-in CurrPage.SetSelectionFilter to capture only the selected records.
    Example:
     
    trigger OnAction()
    var
        RecSelected: Record Customer;
    begin
        CurrPage.SetSelectionFilter(RecSelected);
        if RecSelected.FindSet() then
            repeat
                // Your email-sending logic here
                SendEmail(RecSelected."E-Mail");
            until RecSelected.Next() = 0;
    end;
     
    This ensures only the records the user selected on the list page are processed.
     
    Thanks
    Rishabh
     
  • Suggested answer
    Nimsara Jayathilaka. Profile Picture
    5,128 Super User 2026 Season 1 on at
    Hi
     
    Use CurrPage.SelectionFilter in a multi-select list page to loop through only the user-selected lines and pass their data to your function.
     
    Thanks
    Nimsara
  • Suggested answer
    Nimsara Jayathilaka. Profile Picture
    5,128 Super User 2026 Season 1 on at
    Hi
     
    Use CurrPage.SelectionFilter in a multi-select list page to loop through only the user-selected lines and pass their data to your function.
     
    Thanks
    Nimsara
  • Suggested answer
    YUN ZHU Profile Picture
    101,995 Super User 2026 Season 1 on at
    Hi, hope the following helps as well.
    Dynamics 365 Business Central: How to get a filter for the selected records on any page (For example, ‘1..3|6’)
    Dynamics 365 Business Central: How to use Page.SetSelectionFilter Method in temporary records
    Dynamics 365 Business Central: How to note the records that the user has selected on the Subpage/Lines (Page.SetSelectionFilter in part)
    Dynamics 365 Business Central: About the automatic filtering problem after using Page.SetSelectionFilter Method
     
    Thanks.
    ZHU

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 Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,344 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,742 Super User 2026 Season 1

#3
AndrewThomas81 Profile Picture

AndrewThomas81 1,231

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans