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...
Answered

Convert GetSelectionFilter() to array of integer

(0) ShareShare
ReportReport
Posted on by 67

Hi!

I need to split my Text to Integer array. I want to store selected records Id in array.

My Code looks like this:

trigger OnAction()
var
    SalesNoList: Array[10] of Integer; //is there any way to declare unlimited array size?
    Txt: text;
begin
    Txt := GetSelectionFilter();
    SalesNoList := //what here?
end;

procedure GetSelectionFilter(): Text
var
    SalesTable: Record MySalesTable;
    SelectionFilterManagement: Codeunit SelectionFilterManagement;
    RecRef: RecordRef;
begin
    CurrPage.SetSelectionFilter(SalesTable);
    RecRef.GetTable(SalesTable);
    exit(SelectionFilterManagement.GetSelectionFilter(RecRef, SalesTable.FieldNo("Sales No.")));
end;


1. How to declare unlimited array size? 

2. How to assign it to integer array with parse text to integer?

Best Regards!

  • Suggested answer
    Inge M. Bruvik Profile Picture
    1,021 Moderator on at
    RE: Convert GetSelectionFilter() to array of integer

    Happy to hear that you got it solved!

    And the best solutions are those you find yourself with someone pointing you in the correct direction.

  • Alzack18 Profile Picture
    67 on at
    RE: Convert GetSelectionFilter() to array of integer

    Problem solved!

    NorthW I didn't use what you pointed out, but thanks to this I found the path to the correct solution!

    My code:

    trigger OnAction()
    var
        SalesTable: Record MySalesTable;
    begin
        CurrPage.SetSelectionFilter(SalesTable);
        SalesTable.Next(); //pass record 0
    
        repeat
            Message('%1', SalesTable."Sales No.");
        until SalesTable.Next() = 0;
    end;


    Thank you all for help.
    Best Regards!

  • Suggested answer
    Inge M. Bruvik Profile Picture
    1,021 Moderator on at
    RE: Convert GetSelectionFilter() to array of integer

    I think what you are looking for is the record.marked and record.markedonly functions:

    learn.microsoft.com/.../record-mark-method

    learn.microsoft.com/.../record-markedonly-method

  • Alzack18 Profile Picture
    67 on at
    RE: Convert GetSelectionFilter() to array of integer

    Hi, thank you all for response! :)

    NorthW

    Is there any faster way to get selected records IDs?

    If I select records 1,3,4,5 I get the text "1|3..5". There will be a lot of work in converting this to single values. Isn't there a built-in method in BC that does something like this? :) After all, when we select records and click the standard "Delete", somehow the system does it :D

    When I get those single values I want to pass them to procedure in loop.

    MakeSomething(Id: Integer)

    MakeSomething(1);

    MakeSomething(3);

    MakeSomething(4);

    MakeSomething(5);

  • Suggested answer
    Inge M. Bruvik Profile Picture
    1,021 Moderator on at
    RE: Convert GetSelectionFilter() to array of integer

    1) The limitation for an array in AL is 1000000 elements and 10 dimensions.

    learn.microsoft.com/.../devenv-array-methods

    2) To assign a text to an integer you have to use the evaluate methode

    Evaluate(SalesNoList[1],YourText);

    learn.microsoft.com/.../system-evaluate-method

  • Suggested answer
    DAnny3211 Profile Picture
    9,276 Moderator on at
    RE: Convert GetSelectionFilter() to array of integer

    hi

    look this

    forum.mibuso.com/.../how-to-do-string-split-in-nav

    concerns nav but you can also apply it to BC

    making an unlimited array is not possible

    DANiele

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 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,261 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 233,013 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans