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 / Refresh textbox unique...
Power Apps
Unanswered

Refresh textbox unique ID every second

(0) ShareShare
ReportReport
Posted on by

Hi Experts,

 

I have a powerapps that is being used by lots of people at the same time (on occasions) that is patching the submitted information into a SharePoint list, I have the unique ID field but as people are using the app at the same time, the unique ID is sometimes being used twice. I've created a textbox that shows the unique ID and it then puts the result into the body of an email that is sent on submit. The code for showing my unique ID is below, is there a way of refreshing this text box every second so that it's always true? 

 

First(Sort(QualityPortal,ID,Descending)).ID+1

 

 

Thanks in advance!

 

Categories:
I have the same question (0)
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Dave-ITMan 

    Your problem with this approach is that your app is going to grind to its knees!  In order to get the current next ID, you are going to need to refresh your QualityPortal data source.  Doing a Refresh on the data source every second will cause the app to deadlock.  A refresh typically takes more than a second to complete.

     

    My suggestion is that you let the ID be the ID!  It is unique all the time when you create a new record.  So, there is no need to assign one yourself (and, you can't assign an ID as the primary key).

     

    If you are using the ID to generate some other formatted ID (ex: MMDDYYY-ID) then I would recommend either of the below solutions:

    1) Let PowerAutomate do the work.  It can trigger when a record is created and generate your formatted ID.

    2) Use a calculated column.  You will not be able to get the value of it prior to submitting, but once submitted, the submit will return the calculated value.

    3) Refresh the datasource prior to submitting.  This will consume time in your app, and is still not guaranteed to produce accurate results (as someone else can submit from the point of refresh to the point of submit)

     

    Any of the above are viable options.

     

    I hope this is helpful for you.

  • Dave-ITMan Profile Picture
    on at

    Hi @RandyHayes ,

     

    Thanks for the response. 

     

    There's no extra bits to it in the sharepoint list, it's literally just a unique ID column with a number from 1-100000000+

     

    The only reason for displaying the ID is so that when it sends the email to the user to let them know a new issue has been logged, in the body of the email it shows the Unique ID that is being assigned and all the information logged then gets patched to the sharepoint list. As part of the email, it sends attachments too. I've then got powerautomate that sends the attachments (photo's that have been done by the user) to the correct line item in the sharepoint list. My concern is that if 2 people log at the same time then the pictures could get added to the wrong row. Only using powerautomate because I don't know of a way of adding the images in a collection to sharepoint without using powerautomate, i'd much rather do it within PowerApps so everything is in one place.

     

    Hopefully that makes better sense? 

     

    Regards

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Dave-ITMan 

    Then the ID is the only column you really need!

     

    How are you submitting your data - through a Form or via Patch?

  • Dave-ITMan Profile Picture
    on at

    Hi @RandyHayes ,

     

    I'm submitting it all via patch. The submit button sends the email and also sends the patch at the same time. If I add the below code to the start of my email and patch code, would that work or do I need to add a 10 second delay to give it chance to refresh before sending the email and the patch? 

    Refresh(QualityPortal);

     

    Regards

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Dave-ITMan 

    You don't need to do any refresh.

    What you do need to do is get the result of your Patch.  It will have the ID that was assigned.  You can then use that to send your email and any other action you have that needs the ID.

     

    ex:

    With(Patch(yourDataSource, {yourRecord}),
    
     SendEmail(emailAddress,
     Subject,
     $"The following record ID was created: {ID}"
     )
    )

    Purely pseudo formula, but you can see the structure of what is needed.

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 358 Most Valuable Professional

#2
11manish Profile Picture

11manish 207 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 150 Super User 2026 Season 2

Last 30 days Overall leaderboard