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 :
Small and medium business | Business Central, N...
Answered

How to check Duplicate Records using AL code?

(0) ShareShare
ReportReport
Posted on by 2,122

Hi All,

I need to check the duplicate records from the table and if I found duplicate address in the records then I need to move that record in the Custom Log table,

So, can anyone tell me How Can I check the duplicate records in the AL?

Thank You.

  • Suggested answer
    Nitin Verma Profile Picture
    21,812 Moderator on at

    Hi,

    Can you export all the data using config. package? or use Edit in Excel feature of the page.

    Thanks.

  • Inkey Solutions Profile Picture
    2,122 on at

    Hi, Nitin Verma ,

    I need to do it dynamically, so can you please provide any suggestion that is used by AL code? Thanks.

  • Suggested answer
    Nitin Verma Profile Picture
    21,812 Moderator on at

    There is no way to do it dynamically in standard system. You need to customize it.

  • Inkey Solutions Profile Picture
    2,122 on at

    Hi, Nitin Verma ,

    I tried this code, does this works?

    pastedimage1676354839946v1.png

  • Suggested answer
    Nitin Verma Profile Picture
    21,812 Moderator on at

    PS - ALWAYS SEND CODE IN TXT FORMAT

    You can try to put logic like this.

    If you want me to edit it. share you code in txt format.

    Thanks.

  • Inkey Solutions Profile Picture
    2,122 on at

    Nitin Verma :

    Here it is,

    [EventSubscriber(ObjectType::Table, Database::"Fixed Asset", 'OnAfterModifyEvent', '', false, false)]

    begin

    if rec.Address1 <> '' then begin

               Rec.SetRange(Address1, Rec.Address1);

               if Rec.FindSet() then begin

                   Message('Duplicate Found');

               end else begin

                   Message('Not Found');

               end;

        end;

    end;

  • Suggested answer
    Nitin Verma Profile Picture
    21,812 Moderator on at

    You can try this

       [EventSubscriber(ObjectType::Table, Database::"Fixed Asset", 'OnAfterModifyEvent', '', false, false)]

       local procedure OnAfterModifyEventFA(var Rec: Record "Fixed Asset")

       var

           FixedAsset: Record "Fixed Asset";

       begin

           if rec.Address1 <> '' then begin

               FixedAsset.Reset();

               FixedAsset.setfilter(Address1, Rec.Address1);

               if FixedAsset.Count > 1 then

                   Message('Duplicate Found')

               else

                   Message('Not Found');

           end;

       end;

  • Inkey Solutions Profile Picture
    2,122 on at

    Thank You Nitin Verma , this is works for me.

    Can you tell us that How we can prevent the Insertion of duplicate records? [we want that do not allow the insert duplicate records.]

  • Suggested answer
    Nitin Verma Profile Picture
    21,812 Moderator on at

    You need to write the code OnbeforeInsert event and put the error if any duplicate found or ignore the record by putting Error('')

    Thanks

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 755 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 413 Super User 2026 Season 2

#3
AndrewThomas81 Profile Picture

AndrewThomas81 387 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans