Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Remove duplicate value from temp table

(0) ShareShare
ReportReport
Posted on by 1,392

Hello,

After calling this function i get a result like this :

No. Name
1 AA
2 AA
3 AB
4 AC
5 AB

I want to remove duplicate value {AA,AB} 

LOCAL GetRessourcePerProject(VAR pVendor : Record Vendor)

JobLedgerEntry.SETRANGE(JobLedgerEntry."Job No.",Job."No.");
JobLedgerEntry.SETFILTER(JobLedgerEntry."Document No.",'%1|%2','NDY*','ODK*');
i:=0; IF JobLedgerEntry.FINDSET THEN REPEAT VendorLedgerEntry.SETRANGE(VendorLedgerEntry."Document No.",JobLedgerEntry."Document No."); IF VendorLedgerEntry.FINDFIRST THEN Vendor.SETRANGE(Vendor."No.",VendorLedgerEntry."Vendor No."); IF Vendor.FINDFIRST THEN BEGIN pVendor.INIT; pVendor."No." := FORMAT(i); pVendor.Name := Vendor.Name; pVendor.INSERT; i+=1; END; UNTIL JobLedgerEntry.NEXT = 0;


best regards

*This post is locked for comments

  • Verified answer
    Binesh Profile Picture
    7,885 on at
    RE: Remove duplicate value from temp table

    Hello Medo,

    See the bellow updated code and update your old code.

    Note: we are not aware about your table, but as per standard it's working.

    Here I'm removing a record that have same "Document No." -> so that you will get only one record as per "Document No."

    2017_2D00_05_2D00_22_5F00_19_2D00_38_2D00_28.png

  • Verified answer
    Amol Salvi Profile Picture
    18,696 on at
    RE: Remove duplicate value from temp table

    LOCAL GetRessourcePerProject(VAR pVendor : Record Vendor)

    JobLedgerEntry.SETRANGE(JobLedgerEntry."Job No.",Job."No.");

    JobLedgerEntry.SETFILTER(JobLedgerEntry."Document No.",'%1|%2','NDY*','ODK*');

    i:=0;

    IF JobLedgerEntry.FINDSET THEN

     REPEAT

       VendorLedgerEntry.SETRANGE(VendorLedgerEntry."Document No.",JobLedgerEntry."Document No.");

         IF VendorLedgerEntry.FINDFIRST THEN        

             Vendor.SETRANGE(Vendor."No.",VendorLedgerEntry."Vendor No.");

               IF Vendor.FINDFIRST THEN  BEGIN

                    pVendor.RESET;

                    pVendor.SETRANGE(pVendor.Name,Vendor.Name)

                    IF NOT PVendor.FindFirst THEN BEGIN

                     pVendor.INIT;

                     pVendor."No." := FORMAT(i);

                     pVendor.Name := Vendor.Name;

                     pVendor.INSERT;

                     i+=1;

                   END;

               END;

    UNTIL JobLedgerEntry.NEXT = 0;

  • Suggested answer
    Marcellus Profile Picture
    2,735 on at
    RE: Remove duplicate value from temp table

    Hi Medo,

    You could check if the name already exist in the table before you insert.

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics NAV (Archived)

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans