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

Autoincrement of a number in Powerapp

I am using SharePoint list customize form and creating an auto increment request#. Sharepoint is the datasource. Using the formula Last('Training-Request').'Request#' + 1 in powerapps, where Request# is a column on the sharepoint list and Training-Request is the name of the list. But if two persons simultaneously try to create a request OR if the second person tries to create a request before first person saves it and when second person tries to save, it shows an error that the number is not unique. Seems both the requests pulls the same last request number.

Request your help on how to resolve this issue. I

There is an autoincrement ID in Sharepoint, but it starts with 1, but need to start from a different number, that is why im not using sharepoint ID column.

1 ACCEPTED SOLUTION

Accepted Solutions
Super User III
Super User III

@praveencb16 

This is one of those conditions you're going to have to plan around.  You are definitely going to have situations where multiple users on new or updates will race the results.  

What you might consider is putting in a separate "supporting" list to your SharePoint list.  In that list you could have one record with the currentRequestNumber in it.

Then, when you go to submit, do a lookup on that list to get the "at this moment" current request number.  Then update your list with it and also update the supporting list with that.  This way, when the second user goes to submit, their submit will do the same.  You'll always have an accurate number that way.

You could also do this as part of your actual list (using Max function and so forth), but I don't know if you will ever run into delegation issues with your first list that could cause problems with that.  I can, however, pretty much guarantee you that you'll never have a delegation issue with 1 record in the supporting list.

 

Just a suggestion - hope it sheds some fuel for thought.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

6 REPLIES 6
Super User III
Super User III

@praveencb16 

This is one of those conditions you're going to have to plan around.  You are definitely going to have situations where multiple users on new or updates will race the results.  

What you might consider is putting in a separate "supporting" list to your SharePoint list.  In that list you could have one record with the currentRequestNumber in it.

Then, when you go to submit, do a lookup on that list to get the "at this moment" current request number.  Then update your list with it and also update the supporting list with that.  This way, when the second user goes to submit, their submit will do the same.  You'll always have an accurate number that way.

You could also do this as part of your actual list (using Max function and so forth), but I don't know if you will ever run into delegation issues with your first list that could cause problems with that.  I can, however, pretty much guarantee you that you'll never have a delegation issue with 1 record in the supporting list.

 

Just a suggestion - hope it sheds some fuel for thought.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

View solution in original post

Anonymous
Not applicable

Thanks for posting in the community @praveencb16 - can you review the above reply and update the thread if it was helpful?

 

Thank you,

 

@Anonymous 

Thanks for the suggestion. But even if i collect the data at the time of submitting, it collected the data when powerapps was opened. Refreshing the sharepoint page before submitting resolved the issue. Im not sure if there is anything missing, but it seems to work. 

@praveencb16 

The key in the suggestion was that "when you go to submit" THEN you do the lookup on the value in the list to get the latest number to use.  Chances of that being duplicated would be rare.

Sounds like you are getting through it though, so that's good, but keep it in your back pocket in case you run into the issue again.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!
Helper III
Helper III

Hello @praveencb16 

 

can you please post how and where you use the formula which you mention

 

Last('Training-Request').'Request#' + 1

 

in powerapps?

 

i tried it in a FLOW when i create a new it as expression and gives me an error.

 

here is my expression:  Last('Test'),'IDnr'+1

 

thank you

 

 

 

@kouliscon 

This topic is over a year old and closed.  You might want to post a new topic and reference this one as a link so that it gets a higher level of view and response.

 

To answer quickly though - You would want to do the check in PowerApps prior to submitting the record you want.  This would mean a refresh of the DataSource and then the formula to determine the next number.

 

If that doesn't help any, then I suggest a new topic post and then I can reply there as well as give others a chance to review, learn, and solve also.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (12,934)