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

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Filter Order Sales Line with C/AL Code

(0) ShareShare
ReportReport
Posted on by 159

Hi NAV Experts

I'm filtering order lines with C/AL code

This is my code

VarSalesOrderLines.SETRANGE("Document Type",Rec."Document Type");
VarSalesOrderLines.SETRANGE("Document No.",Rec."No.");

this returns only one record

How can I filter this records in C/AL Code?

query.png

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Community Member Profile Picture
    on at
    RE: Filter Order Sales Line with C/AL Code

    You can use the following line.

    VarSalesOrderLines.SETFILTER("Document No.",'%1','PED-1106*');

  • RockwithNav Profile Picture
    8,415 Super User 2025 Season 2 on at
    RE: Filter Order Sales Line with C/AL Code

    Hey Angel,

    Code syntax should be like this - 

     

    VarSalesOrderLines.SETRANGE("Document Type",Rec."Document Type");

    VarSalesOrderLines.SETRANGE("Document No.",Rec."No.");

    IF VarSalesOrderLines.FINDSET THEN

    REPEAT

    // Here it will make loop and will check for all Records

    UNTIL VarSalesOrderLines.NEXT=0;

     

     

    VarSalesOrderLines.SETRANGE("Document Type",Rec."Document Type");

    VarSalesOrderLines.SETRANGE("Document No.",Rec."No.");

    IF VarSalesOrderLines.FINDFIRST THEN

    // This line of code will look for the first record only.

     

    Thanks

    Blog - http://rockwithnav.wordpress.com/

     

  • Angel Arteaga Profile Picture
    159 on at
    RE: Filter Order Sales Line with C/AL Code

    Thanks it works fine!

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

#1
Saurav.Dhyani Profile Picture

Saurav.Dhyani 2 Super User 2025 Season 2

#1
Alexander Ermakov Profile Picture

Alexander Ermakov 2

#3
RK-25090803-0 Profile Picture

RK-25090803-0 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans