web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Validate button add in form to not to allow duplicate entries in table

(0) ShareShare
ReportReport
Posted on by

Hi All,

i have created a form . user don't wants to allow duplicate entries...
for this i put indexing on table based on columns...
it's working fine when user going to save record in form it's throwing an error " Record already exist ". as per standard behavior.
BUT
customer wants to do that in different way...
they told me to add button VALIDATE in form. when user click on this Validate button then it will check duplicate record in table and not allow to save also.

We need data in form always when user opening a form.

Kindly let me know how to do this...

Please give me more shed on this.

Thanks!

*This post is locked for comments

  • Sukrut Parab Profile Picture
    on at
    RE: Validate button add in form to not to allow duplicate entries in table

    When system can handle what you need with just index , it doesn't make sense to add validate button . Also what do you mean by "we need data in form always"

  • @rp@n Profile Picture
    on at
    RE: Validate button add in form to not to allow duplicate entries in table

    Thanks Sukrut

    we need data in form always means I used regular table. nothing else

  • Verified answer
    nmaenpaa Profile Picture
    on at
    RE: Validate button add in form to not to allow duplicate entries in table

    You can add a button and in the clicked method call validateWrite of your form data source. Then you'll see the same warning/error (which is still controlled by the index). But that doesn't make any sense. The record is validated automatically every time it's changed or added so you don't need this button.

    You can ask your customer to click Save if they need to validate. And this doesn't require any development so it's free for them!

  • Blue Wang Profile Picture
    on at
    RE: Validate button add in form to not to allow duplicate entries in table

    Hi @rp@n,

    You can customize the creation of your unique index to avoid duplication.

    You can refer this: https://docs.microsoft.com/en-us/dynamicsax-2012/developer/indexes-overview.

    Besides, If you want, you could override aosValidateWrite() .

  • @rp@n Profile Picture
    on at
    RE: Validate button add in form to not to allow duplicate entries in table

    Thanks Nikoloas,

    So, you suggest me to create a index with combination. Means I need to add ( multiple columns). based on combination  it should be unique each row.

    Please give me more shed on this.

  • Suggested answer
    nmaenpaa Profile Picture
    on at
    RE: Validate button add in form to not to allow duplicate entries in table

    If you need to prevent duplicates for field combination FieldA, FieldB and FieldC, you need to create an index that has these three fields and has AllowDuplicates:No.

    Is this the shed you need? To me it seems you described in your first message that you already created such index. There's no more shed to be added to that.

  • @rp@n Profile Picture
    on at
    RE: Validate button add in form to not to allow duplicate entries in table

    Yes Nikoloas, I need that only.

    But I got DB Synchronization error after creating an index. when synchronisze the table. I did whole data dictionary also

    for the time begins instead of creating index in table shall I go to call Validatewrite() in clicked(). it will work?

    Please give me more shed on this.

  • Verified answer
    nmaenpaa Profile Picture
    on at
    RE: Validate button add in form to not to allow duplicate entries in table

    You must remove all duplicates from the table before you can synchronize. Just clean up the duplicates and the sync will succeed.

    The validateWrite approach is also relying on the same index, so it will not work if you don't have the index.

    Without the index you can't be sure that nobody inserts duplicates in the table. If you think about only relying on a button, nothing else, the user can just not click the Validate button before saving the record.

  • @rp@n Profile Picture
    on at
    RE: Validate button add in form to not to allow duplicate entries in table

    Hi Nikoloas,

    Yes, I removed all duplicates record from Table and perform

    2287.A2.jpg

    2287.A2.jpg

    It's throwing error perfectly but why saved record in Table? I not understand.

    Please give me more shed on this

  • Suggested answer
    nmaenpaa Profile Picture
    on at
    RE: Validate button add in form to not to allow duplicate entries in table

    What do you mean "saved record in the table"? Is this record in the table, having duplicate values? I don't think so (assuming you created the index and synchronized the database).

    By the way, normally it's a good practice to set AllowEdit to No on all fields that are part of your unique index. Just have AllowEditOnCreate to be true.

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans