cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Black_Magic100
Level: Powered On

Why does auto number work some of the time and other times it doesn't at all?

I am using CDS for Apps as my data source. I have two entities. One entity has an auto number ID column so theoretically every time a new row is added an incrementing ID should be as well. It worked great, until it stopped randomly while user testing my app. Please help. There is no articles online of my issue
1 ACCEPTED SOLUTION

Accepted Solutions
Helpful
Level 8

Re: Why does auto number work some of the time and other times it doesn't at all?

If you’re building a model-based app there shouldn’t be any code needed.  I’ve been working with these the last few days and while there are some gotchas they seem to work pretty well.

Things I’ve learned:

  • If you add an autonumber field to an entity that has data, you will have to assign values manually (perhaps obvious)
  • Once created, do not expect to mess with the format or seed - particularly after values have been assigned
  • Seed values do not get deployed with solutions
  • Best not to make them required
  • They are writeable by users so adding them as read-only form field produces best result
  • If one is entered manually (say through Excel) the system will accept it according to basic string length rules on the field AND if you want to give it a conforming value to your autonumber sequence/specification you’ll have to identify that value and apply it manually.
  • It has no relationship to the "Auto numbering" capability in Data Management settings of the environment

Hopefully one of these will be useful.  If you’re working exclusively through the UI and not supplying a value at the time of record creation it should work reliably.  Let us know if you have other circumstances.

View solution in original post

3 REPLIES 3
Community Support Team
Community Support Team

Re: Why does auto number work some of the time and other times it doesn't at all?

Hi @Black_Magic100 ,

 

Did you mean the auto-number attribute added programmatically following below documentation?

https://docs.microsoft.com/en-us/powerapps/developer/common-data-service/create-auto-number-attribut...

 

What did you mean by "it stopped randomly"? Could you please describe in detail about this behavior?

 

Regards,

Mona

Community Support Team _ Mona Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Black_Magic100
Level: Powered On

Re: Why does auto number work some of the time and other times it doesn't at all?

Wait, do I actually have to do this programmtically?  Can I not just create a column that is of type 'Autonumber'.  It seems to be working without failure now, but before it would sometimes not generate the column for no reason.  I interpreted autonumber column as a way to automically generate a surrogate key like you would in a SQL database table, only instead of writing a few lines of code you just select Autonumber.  

Helpful
Level 8

Re: Why does auto number work some of the time and other times it doesn't at all?

If you’re building a model-based app there shouldn’t be any code needed.  I’ve been working with these the last few days and while there are some gotchas they seem to work pretty well.

Things I’ve learned:

  • If you add an autonumber field to an entity that has data, you will have to assign values manually (perhaps obvious)
  • Once created, do not expect to mess with the format or seed - particularly after values have been assigned
  • Seed values do not get deployed with solutions
  • Best not to make them required
  • They are writeable by users so adding them as read-only form field produces best result
  • If one is entered manually (say through Excel) the system will accept it according to basic string length rules on the field AND if you want to give it a conforming value to your autonumber sequence/specification you’ll have to identify that value and apply it manually.
  • It has no relationship to the "Auto numbering" capability in Data Management settings of the environment

Hopefully one of these will be useful.  If you’re working exclusively through the UI and not supplying a value at the time of record creation it should work reliably.  Let us know if you have other circumstances.

View solution in original post

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (5,350)