Greetings all,
I want to add a new method in my table to prevent the same value in the column from showing up. what method should i use?
Greetings all,
I want to add a new method in my table to prevent the same value in the column from showing up. what method should i use?
Since it's your own code, just add code that checks whether a duplicate record already exists in the table. If it does, don't insert a new row.
Please check this doc page to learn how to select (find) records in a table: hdocs.microsoft.com/.../select-statements
Hi Nikolaos
Sorry, when I said "filter out", it means that the table keeps inserting the same ID (which is the unique index I just did on the table that I want).
so basically this data is created from importing .csv files, this import method is placed in a class. there's also a form and a button in it to import the files. the form and data source(same table) has 2 columns which one of is ID, so when I successfully imported the .csv file, the table or form appear to have duplicated records that have the same ID
and quoting for the "it keeps inserting the same value of ID", it means that the .csv file contains various records with the same ID
(eg: location ID
address 1
city 1
,I just want to filter the records to select only one value of ID (doesn't matter which record because i have a second form to show all the record) to appear on my table
Hi fireblaster,
what do you mean "filter out"? Earlier you wrote "prevent the same value in the column from showing up".
You also wrote "it keep inserting the same value of ID"
I think it would be good if you could share a bit more details about your scenario. What's "it"? How is this data created and where?
Unique indexes are the standard way to prevent duplicates - not only in AX but in databases in general.
I warmly recommend that you stick with the logic of the standard application, this way it's easy for the users to understand how things work. Users can try to insert duplicate records, and they will see an error if they try to do so.
It's up to the user (or your code, depending how the data is created) to handle the error or check for duplicates. The target table's responsibility is to prevent duplicates from being inserted, by throwing an error.
the ID that i created have a string value, so when i inserted into my table, it will filter out the same ID if existed
Right, so the index itself won't generate a new Id for you, it'll only prevent duplicates from being inserted in the database by throwing an exception.
What's your specific requirement? Remember you already have RecId for unique records, is this Id you created a numeric value that you want to auto increment just to show to the user? Is it a natural key?
I already done it but, it keep inserting the same value of ID
Hi,
That can be achieved by adding an index to the table. Just add the field/s that make up the key, and set the property Allow duplicates to No for that key.
André Arnaud de Cal... 291,280 Super User 2024 Season 2
Martin Dráb 230,235 Most Valuable Professional
nmaenpaa 101,156