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

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

How to select only distinct records from a table?

(0) ShareShare
ReportReport
Posted on by 607

Hi All,

I am quite new to NAV. I want to select distinct rows from a table? 

Thanks in Advance.

I have the same question (0)
  • Saurav.Dhyani Profile Picture
    14,380 Super User 2025 Season 2 on at

    Hi Axboy,

    Can you provide an example and for which version of NAV / BC?

  • AXBOY Profile Picture
    607 on at

    It's for business Central.

    I have to select all the records from JoB table whose type is resource and that too resource.typpe: Person. Then from these records I want only those records whose person name is unique.

  • Suggested answer
    Saurav.Dhyani Profile Picture
    14,380 Super User 2025 Season 2 on at

    I think you are referring table Resource not Job.

    Below code sample will show those unique Resource Name -

    LOCAL GetUniqueResources()

    Resource.RESET;

    Resource.SETCURRENTKEY("Name");

    Resource.SETRANGE(Type,Resource.Type::Person);

    IF Resource.FINDSET THEN REPEAT

     IF PrevResourceName = Resource.Name THEN

       MESSAGE('%1',Resource.Name);

     PrevResourceName := Resource.Name;

    UNTIL(Resource.NEXT=0);

    I hope it helps.

  • AXBOY Profile Picture
    607 on at

    Hi Saurav, thanks for the reply.

    I have Job No. with me , and using that i want to build a string with Job.Description , of planning lines type=resource, resource.type=person with unique Job.No values. Can u pls help me with this?

  • Saurav.Dhyani Profile Picture
    14,380 Super User 2025 Season 2 on at

    You need to share an example what you want before i can help you.

  • AXBOY Profile Picture
    607 on at

    I am building a report where the user will select a Job Number and based on that number report will print data from the Job Planning lines related to that Job Number.

    Now for one of the fields ,i have display a string in the form: JobPlanning.Description1,JobPlanning..Description2, JobPlanning.Description3.....etc , where JobPlanning.Type = Resource and that Resource.Type= Person.

    I am able to achieve till here, but i want the String to have unique Description , that is i do not want that string to contain duplicate Person names. Hope you get my point.

  • Saurav.Dhyani Profile Picture
    14,380 Super User 2025 Season 2 on at

    Sorry, I still didnt understand.

    I may need some sample data to understand requirment.

  • Suggested answer
    Raju Gudipalli Profile Picture
    185 on at

    Use code like this to eliminate the duplicates

    Mydescription : text;

    If strpos(mydescription,jobplanninglines.description)  = 0 then

    Mydescription += jobplanninglines.description.

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,577

#2
YUN ZHU Profile Picture

YUN ZHU 888 Super User 2025 Season 2

#3
Jainam M. Kothari Profile Picture

Jainam M. Kothari 778 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans