web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Answered

SetSelectionFilter to get multiple lines as report parameter

(0) ShareShare
ReportReport
Posted on by 1,165

Hi All,

Trying to create code to get multiple document numbers selected on sales invoices list page so I can pass this to a report parameter like 100007|100008 format.

However I get results like |100007|100008 format 

code:

                    CurrPage.SETSELECTIONFILTER(SalesInvHeader)

                    IF SalesInvHeader.FINDFIRST then begin

                        REPEAT

                           

                            noFilter := noFilter + '|';

                            noFilter := noFilter + SalesInvHeader."No."; 

                        UNTIL SalesInvHeader.NEXT = 0;

                        CLEAR(SalesInvHeader);

                        SalesInvHeader.SETFILTER("No.", noFilter);

  • Dhan Raj Bansal Profile Picture
    679 on at

    Try following:

    REPEAT

      noFilter += SalesInvHeader."No."+ '|';

                           UNTIL SalesInvHeader.NEXT = 1;

    SalesInvHeader.next;

    noFilter+=SalesInvHeader."No."

    But what is the length of noFilter & how many records are there in SalesInvHeader in repeat loop? Take care of over conversion, string length related issue..

  • Anita75 Profile Picture
    1,165 on at

    Changed the code as below, but only first and last marked invoice is copied to parameter so if i select inv number 100001,100002,100003 then it sets it as 100001|100003 missing records in middle.

                               noFilter += SalesInvHeader."No." + '|';

                           UNTIL SalesInvHeader.NEXT = 1;

                           SalesInvHeader.next;

                           noFilter += SalesInvHeader."No.";

                           CLEAR(SalesInvHeader);

                           SalesInvHeader.SETFILTER("No.", noFilter);

                       END;

                       //

                       REPORT.RUNMODAL(51306, TRUE, FALSE, SalesInvHeader);

  • Verified answer
    Dhan Raj Bansal Profile Picture
    679 on at

    Try with more number of records, my earlier solution should have work, give it another try. 

    Another solution: 

    IF SalesInvHeader.FINDFIRST then begin

                            REPEAT

                               

                                noFilter +=  SalesInvHeader."No."+'|': 

                            UNTIL SalesInvHeader.NEXT = 0;

    noFilter:=copystr(noFilter,1,stellen(noFilter)-1):;

  • Anita75 Profile Picture
    1,165 on at

    Awsome ..works now ..thanks

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

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 710 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 387 Super User 2026 Season 2

#3
AndrewThomas81 Profile Picture

AndrewThomas81 385 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans