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.
You need to write the code OnbeforeInsert event and put the error if any duplicate found or ignore the record by putting Error('')
Thanks
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.]
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;
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;
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.
Hi, Nitin Verma ,
I tried this code, does this works?
There is no way to do it dynamically in standard system. You need to customize it.
Hi, Nitin Verma ,
I need to do it dynamically, so can you please provide any suggestion that is used by AL code? Thanks.
Hi,
Can you export all the data using config. package? or use Edit in Excel feature of the page.
Thanks.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,232 Super User 2024 Season 2
Martin Dráb 230,064 Most Valuable Professional
nmaenpaa 101,156