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)

How to display a list of documents filtered by the customer number? (Is my code good?)

(0) ShareShare
ReportReport
Posted on by

Hello everyone,


I need to create an action button which displays a list of documents linked to a specific customer. Can anyone check and correct if the code below is fine?


lAction := lAnomalyList.RUNMODAL;
IF lAction = ACTION::LookupOK THEN BEGIN
lAnomalyHeader.SETRANGE("Customer No.", lCustomer."No.");
  //lAnomalyList.SETSELECTIONFILTER(lAnomalyHeader);
  lAnomalyHeader.FINDSET ;
  lAnomalyList.SETRECORD(pRec) ;
  lAnomalyList.RUN ;
END;

Thank you!

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Nareshwar Raju Vaneshwar Profile Picture
    5,596 on at

    Hi Josh,

    As per your requirement, the list will contain the documents of a specific customer, which leads me to assume that the Page action will be in Customer List / Card page.

    I wrote the following code to get the Sales records of the specific Customer, which is straightforward with few lines of code.

    Variables:

    SalesHeader - Table 37.

    SalesByCustomers - A Page object to show the results of your selection.

    //Code start

    SalesHeader.SETRANGE(SalesHeader."Sell-to Customer No.", "No.");
    IF SalesHeader.FINDSET THEN
    BEGIN
        SalesByCustomers.EDITABLE(FALSE);
        SalesByCustomers.SETTABLEVIEW(SalesHeader);
        SalesByCustomers.RUNMODAL;
    END
    ELSE MESSAGE('No Sales records for the customer %1 ', "No.");

    //Code end

    If you are using NAV 2016, you can check FIlterPageBuilder datatype which eases this sort of requirements.

    [1] https://msdn.microsoft.com/en-us/library/dn951487(v=nav.90).aspx

    Hope it helps.

  • Community Member Profile Picture
    on at

    Hello Nareshwar,

    Thank you so much for your time and reply. It works well now! :)

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!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans