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 :
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

    You can use the following line.

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

  • RockwithNav Profile Picture
    9,113 Super User 2026 Season 1 on at

    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

    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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans