Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

Counting records

Posted on by Microsoft Employee

I Am trying to filter within a lookup for purchase lines. I want to say if there is only 1 record after the filter, open up the card page, if there are multiple, open up a listpage with the results.

How can i count the records after the filter. I thought this would work


IF recPurchLine.COUNT = 1 THEN BEGIN;
PAGE.RUN(PAGE::"G/L Receipt Line Receipt Card", recPurchLine);
END ELSE BEGIN
GLLinesFilter(recPurchLine);
PAGE.RUN(PAGE::"G/L Receipt Lines List", recPurchLine);
END;

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Counting records

    Yes thank you, the following solution worked.

    My assumption was the filters would come through from a previous function.

    IF NOT GLLinesExist THEN

     EXIT;

    GLLinesFilter(recPurchLine);

    intGlLinesCount := recPurchLine.COUNT;

    IF intGlLinesCount = 1 THEN BEGIN

     PAGE.RUN(PAGE::"G/L Receipt Line Receipt Card", recPurchLine);

    END ELSE BEGIN

     PAGE.RUN(PAGE::"G/L Receipt Lines List", recPurchLine);

    END;

    // TIO000006 : END

  • Verified answer
    Jan Veenendaal Profile Picture
    Jan Veenendaal 510 on at
    RE: Counting records

    GLLinesFilter(recPurchLine);

    IF recPurchLine.COUNT = 1 THEN BEGIN

    PAGE.RUN(PAGE::"G/L Receipt Line Receipt Card", recPurchLine);

    END ELSE BEGIN

    PAGE.RUN(PAGE::"G/L Receipt Lines List", recPurchLine);

    END;

    Looks like you did not set the filter before the COUNT ??

  • Suggested answer
    Mohana Yadav Profile Picture
    Mohana Yadav 59,139 Super User 2024 Season 2 on at
    RE: Counting records

    Is it working now?

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Counting records

    * The ; After the BEGIN was a mistake, now removed*

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans