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;
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:
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:
Hope this helps.
Thanks.
ZHU
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.
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’)
Thanks.
ZHU
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.
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.
I will open this up to the community in case they have something to add.
Any suggestion?
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,104 Most Valuable Professional
nmaenpaa 101,156