cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Olav
Frequent Visitor

Autonumber not working anymore

Hi everybody,

 

In the dataverse, i have a table that uses an autonumber column as primary name column. It worked fine until now.

If I add a new value, I always get this error:

A record that has the attribute values id already exists. The entity key idkey requires that this set of attributes contains unique values.

 

If I add a new item and fill in the autonumber column (id) manually with a nonexisting number, it works fine.

1 ACCEPTED SOLUTION

Accepted Solutions
Fubar
Solution Sage
Solution Sage

Not sure what has gone wrong etc, but you probably need to look at your existing data and find the current largest one in the name field, and then on the autonumber definition reset the Seed value higher than that number.

 

As it appears you are allowing data entry into the field it is possible that a number was manually added (or imported) that the autonumber sequence is now also generating the same number and your Alt Key has a uniqueness issue as you now have a duplicate.

(note: autonumber does not look at the current entity for the next number, the actual sequence is held elsewhere)

View solution in original post

6 REPLIES 6
v-xiaochen-msft
Community Support
Community Support

Hi @Olav ,

 

Could you use pictures or some formulas to describe the problem you encountered?

Have you created an Alternate Key for the table?

 

Best Regards,
Wearsky

v-xiaochen-msft
Community Support
Community Support

Hi @Olav ,

 

To make it easier to understand, please check this section.

v-xiaochen-msft_0-1619085030274.png

Its function is to prohibit adding records with duplicate values.

 

If you want to add records with duplicate values, I suggest you delete the key.

 

Best Regards,
Wearsky
If my post helps, then please consider Accept it as the solution to help others. Thanks.

 

Olav
Frequent Visitor

Thank you for looking at my question.

So, I have a table: "ExampleTable". This has a primary name column: "Id" with type autonumber. So each time the user adds a new record, the system should assign automatically the next number. "Id" is the selected column under keys.

 

Doesn't work:
Patch(ExampleTable, Defaults(ExampleTable));

 

Does work (assuming 123 isn't in the table yet):
Patch(ExampleTable, Defaults(ExampleTable), {Id: 123});

Fubar
Solution Sage
Solution Sage

Not sure what has gone wrong etc, but you probably need to look at your existing data and find the current largest one in the name field, and then on the autonumber definition reset the Seed value higher than that number.

 

As it appears you are allowing data entry into the field it is possible that a number was manually added (or imported) that the autonumber sequence is now also generating the same number and your Alt Key has a uniqueness issue as you now have a duplicate.

(note: autonumber does not look at the current entity for the next number, the actual sequence is held elsewhere)

v-xiaochen-msft
Community Support
Community Support

Hi @Olav ,

 

You still have not answered my question.

Please tell me to troubleshoot the problem.

Have you created an Alternate Key?

 

Best Regards,
Wearsky

The "id" column is the key column. It looks like autonumber reset the next value to a random number. In this case, the next number was 1153, however, I've had elements with id already in 1190. So I put a new seed value in it and now it works again. I can continue working but I still don't know what caused the problem so that's a pity.

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Users online (1,830)