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

GetSelectionFilter + SelectionFilterManagement issue

(0) ShareShare
ReportReport
Posted on by

hi,
I have an AL message that shows my multi-select records i.e., Subs are 166..172
The issue is there is 168 in between the range displayed in the message. How can I show everything instead of range i.e. Subs are 166,168,172

Below is my code

trigger OnLookup(var Text: Text): Boolean
var
CitySubPg: Page Cities;
SubTab: Record Subs;
SelectionFilterManagement: Codeunit SelectionFilterManagement;
RecRef: RecordRef;
begin

CitySubPg.SetTableView(SubTab);
CitySubPg.LookupMode(true);
if CitySubPg.RunModal = ACTION::LookupOK then begin
CitySubPg.SetSelectionFilter(SubTab);
RecRef.GetTable(SubTab);


Message('Subs are %1', SelectionFilterManagement.GetSelectionFilter(RecRef, SubTab.FieldNo("SubCode")));

"CityCode" := SelectionFilterManagement.GetSelectionFilter(RecRef, SubTab.FieldNo(Code));
"SubCode" := SelectionFilterManagement.GetSelectionFilter(RecRef, SubTab.FieldNo("SubCode"));

end;
end;

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

    Any suggestion?

  • Suggested answer
    Andy Sather Profile Picture
    Microsoft Employee on at

    Hello  - We currently do not have dedicated Dev support via the Dynamics 365 Business Central forums, but I wanted to provide you some additional resources to assist.  If you need assistance with debugging or coding I would recommend discussing this on one of our communities.

    www.yammer.com/dynamicsnavdev

    I will open this up to the community in case they have something to add.

  • Suggested answer
    IB-29041624-0 Profile Picture
    1,191 Moderator on at

    Then you have to first set the range for the records and then loop through them and build the filter string as you loop through the records that match your original filter.

    Maybe it is easier to help you if you share your complete code.

  • Suggested answer
    YUN ZHU Profile Picture
    101,995 Super User 2026 Season 1 on at

    Hi, It seems that this requirement is a bit similar to the test I did before. I hope the following information can give you some hints.

    How to get a filter for the selected records on any page (For example, ‘1..3|6’)

    https://yzhums.com/27561/

    pastedimage1677722493337v1.png

    Thanks.

    ZHU

  • Romryan Profile Picture
    on at

    ZHU,

    Yeah but in that message, I need the message to show everything, even the numbers in between the range. As per now instead of showing me 166,168,172 it shows 166..172.

  • Verified answer
    YUN ZHU Profile Picture
    101,995 Super User 2026 Season 1 on at

    Hi, I understand. If so you should try another solution.

    For example, using SelectionFilterManagement.GetSelectionFilter

                action(GetFilterForSelectedRecords)
                {
                    Caption = 'Get Filter For No.';
                    Promoted = true;
                    PromotedCategory = Process;
                    PromotedIsBig = true;
                    PromotedOnly = true;
                    ApplicationArea = All;
                    Image = GetOrder;
                    trigger OnAction()
                    var
                        SalesHeader: Record "Sales Header";
                        SelectionFilterManagement: Codeunit SelectionFilterManagement;
                        RecRef: RecordRef;
                    begin
                        SalesHeader.Reset();
                        CurrPage.SetSelectionFilter(SalesHeader);
                        RecRef.GetTable(SalesHeader);
                        Message(SelectionFilterManagement.GetSelectionFilter(RecRef, SalesHeader.FieldNo("No.")));
                    end;
                }

    Result:

    pastedimage1677741433080v1.png

    Just add a loop.

                action(GetFilterForSelectedRecords)
                {
                    Caption = 'Get Filter For No.';
                    Promoted = true;
                    PromotedCategory = Process;
                    PromotedIsBig = true;
                    PromotedOnly = true;
                    ApplicationArea = All;
                    Image = GetOrder;
                    trigger OnAction()
                    var
                        SalesHeader: Record "Sales Header";
                        SelectionFilterManagement: Codeunit SelectionFilterManagement;
                        RecRef: RecordRef;
                        FilterText: Text;
                    begin
                        FilterText := '';
                        SalesHeader.Reset();
                        CurrPage.SetSelectionFilter(SalesHeader);
                        RecRef.GetTable(SalesHeader);
                        if SalesHeader.FindFirst() then
                            repeat
                                if FilterText = '' then
                                    FilterText := SalesHeader."No."
                                else
                                    FilterText := FilterText   ','   SalesHeader."No.";
                            until SalesHeader.Next() = 0;
                        Message(FilterText);
                    end;
                }

    Result:

    pastedimage1677741735673v2.png

    Hope this helps.

    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