Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX forum
Suggested answer

How to write validate field to stop inserting duplicate records

Posted on by 82
Hey i have a scenario where i need to write validation on table to stop inserting duplicate value on that field on same table.
I can’t use index, how can i achieve it?
  • Mohamed Amine Mahmoudi Profile Picture
    Mohamed Amine Mahmoudi 4,826 User Group Leader on at
    How to write validate field to stop inserting duplicate records
    Hi,
     
    Can you share with me the error message and the table properties ?
     
    Best regards,
    Mohamed Amine MAHMOUDI
  • Community member Profile Picture
    Community member 82 on at
    How to write validate field to stop inserting duplicate records
    I used this i get the error message but the record gets saved, how do i stop it from saving the record
  • Suggested answer
    Mohamed Amine Mahmoudi Profile Picture
    Mohamed Amine Mahmoudi 4,826 User Group Leader on at
    How to write validate field to stop inserting duplicate records
    Hi,
     
    I think you can use a index with Allow duplicate set to No.
    Also you can use the ValidateWrite method on table or table extension to prevent inserting based condition.
    e.g.
    public boolean validateWrite()
    {
        boolean ret;
        
        ret = super();
        if(Condition)
        {
            ret = checkFailed("The record already exist !");
        }
        return ret;
    }
    Best regards,
    Mohamed Amine MAHMOUDI

Helpful resources

Quick Links

Can you answer this forum question?

You could make someone's day!

Community Newsletter - May 2024

Kudos to our community stars!

Community Spotlight of the Month

Kudos to Mohamed Amine Mahmoudi!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 283,632 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 224,528 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,146

Featured topics

Product updates

Dynamics 365 release plans