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

I have the same question (0)
  • Suggested answer
    Marcellus Profile Picture
    2,735 on at

    Hi Medo,

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

  • Verified answer
    Amol Salvi Profile Picture
    18,698 on at

    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;

  • Verified answer
    Binesh Profile Picture
    7,885 on at

    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

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 > 🔒一 Microsoft Dynamics NAV (Archived)

#1
HoangNam Profile Picture

HoangNam 7

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans