Skip to main content

Notifications

Business Central forum
Answered

Convert GetSelectionFilter() to array of integer

Posted on by 65

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!

Categories:
  • Suggested answer
    Inge M. Bruvik Profile Picture
    Inge M. Bruvik 32,744 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
    Alzack18 65 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
    Inge M. Bruvik 32,744 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
    Alzack18 65 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
    Inge M. Bruvik 32,744 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
    DAnny3211 9,217 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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,524 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,469 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans