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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Create unique ID for o...
Power Apps
Unanswered

Create unique ID for observations

(0) ShareShare
ReportReport
Posted on by 6

I am building an app to use for pollinator observations and a new record is created for either a new bee individual or the same bee individual but at a new flower. I created 2 variables in my Sharepoint table, one called FlowerNum and the other BeeNum. The idea is that someone can have an observation of a new individual (users press a button to increase BeeNum) and FlowerNum is set to begin at 1 and then have a second observation of the same individual but at a new flower (users would press a button to increase FlowerNum but BeeNum would stay the same). 

 

I used "OnStart" to create a global variable: Set(varIncrementBee, 1).

I have a button for users to press called "New Bee" and the "OnSelect" properties of that are: Set(varIncrementBee, varIncrementBee+1).

 

I have these observations (including several others) patched to a Sharepoint table. Everything works great with one user. However, when 2 people use the app at the same time they can end up with the same BeeNum. I think the problem is varIncrementBee is always starting at 1. Is there a way to have a unique number for each observation?

 

When I patch each record I use "varNewItem" so I also tried setting the "OnStart" to: Set(varIncrementBee, varNewItem.ID) and the "New Bee" button "OnSelect" properties to Set(varIncrementBee, varNewItem.ID+1). This works somewhat but if you have several observations where you only clicked "New Flower" the next time you create an observation for "New Bee" the BeeNum has skipped several numbers (see attached photo). I'd like it to not miss out on numbers but if this is the best way to get a unique new bee number for each observation/user I will stick with it.

 

Any help is appreciated!

Screenshot 2023-03-06 at 3.38.18 PM.png
Categories:
  • Rusk Profile Picture
    1,369 Super User 2024 Season 1 on at

    Yes it sounds like the issue is with using a variable that increases for each user only.  Set(varIncrementBee, varIncrementBee+1) is not going to know if I'm also using the app and adding bees.  Instead, you can query your SharePoint list when making a new bee:

     

    Max(YourSharePointList,BeeNum)+1

  • rprather Profile Picture
    6 on at

    @Rusk Is there a way to set that as my variable "varIncrementBee" or would I no longer need that variable with your solution? I was patching my data as: BeeNum: varIncrementBee. How would I patch that if I didn't have my variable?

  • Rusk Profile Picture
    1,369 Super User 2024 Season 1 on at

    I would recommending using the Max formula instead of your variable, due to the multiple users.  Although you can still set the variable if you prefer. 

     

    Does your app patch the new bee value right away?  If so, the variable will be fine.  If not, then will a new user "get in the middle" and use the same bee number?  If that occurs, Max is going to be better.

     

    Set(varIncrementBee, Max(YourSharePointList,BeeNum)+1)

    or Patch

     

    {BeeNum: Max(YourSharePointList,BeeNum)+1}

     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 248 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 192 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 135

Last 30 days Overall leaderboard