cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
tagustin2020
Power Participant
Power Participant

Auto-Populate Request Number in a Power Apps Form

@RandyHayes 

 

Hello Randy,

 

I am working on a Shipping Request Power App. I have received a request to auto-populate a sequential req number in the form when the New Request Button is clicked. I have two data sources. The primary list that all form data is written to and a separate list for Shipping Request Number. How do I do a lookup on this list when the New Request button is clicked?

 

Screenshots are attached in the Word doc. Thank you in advance for your help. Teresa

 

ReqNumSS.png

2 ACCEPTED SOLUTIONS

Accepted Solutions
RandyHayes
Super User
Super User

@tagustin2020 

So you're going with a combination of #2 and #3.  The first part is to assign the number in flow, but in order to then get that updated in your datasource, you'll need the expensive refresh on the record...and you'll need to get that after the flow completes.

 

<I'm going to ramble here for just a bit...>

I will throw one other thing out there...sequential numbering is a thing of the past!  It is based on the old paper system where each sheet of a form was numbered sequentially.  Somehow that ancient principal has perpetuated even into today, but, and I only mention this to say...stop!  Do you really need a sequential number?  If there is some essential business process that requires it, then you have no choice.  But, if there is not, then why try to continue it?

 

We abandoned sequential numbering in all our systems and apps over a decade ago because it really had not informational value.  What we went with was more of a date-based numbering such as yymmddhhmmss.  Why this? Because it actually provides value.  Unlike a sequential number such as 10030 that provides no real information, this at least provides an exact time of when the artifact was created. If I pick up an item that 10030 on it, I have no idea if this is old or new or what unless I look it up.  If I pick up an item that has 1902071233 on it, I immediately know that this is two years old.

In most cases we only trail down to the seconds in high load apps.  If there is very minimal risk of a person creating two within the same minute, we skip the seconds.  Likewise if there is not chance of two records being created in the same hour, se skip the minutes...and so on.

 

This provides not only valuable information from the unique ID, but it also plays VERY nicely with PowerApps as there is no flow needed nor and issues with refreshing, writing back, etc.  Just submit and the value exists.  Done.

 

Okay...</end rambling here>

 

Now, back to the story...I believe you might have misunderstood my options (and I might have mislead in number 2).  I gave those for the purpose of specifically meeting the requirement of displaying the Sequential ID AT the time the user is creating the item - that seemed to be what you wanted.  And looking back, #2 would not technically have done that (although for some reason that was in my mind).

 

So, that brings me to the conclusion that since you chose flow,  that showing the Sequential ID at the time the user enters the new record is NOT that important.  

In that case I would very much discontinue the use of flow for this.  You will cost your app more performance issues and complexity than is necessary.

 

Instead, simply change your OnSuccess action of your form to the following:

   UpdateIf(yourList, ID=Self.LastSubmit.ID, {'Request Number': Self.LastSubmit.ID + 10000})

 

That will do the equivalent of the flow without the cost.  And your Gallery will immediately reflect it without any further action.

Keeping in mind, that this is based on what you are currently trying, which implies that displaying the Request number to the user before the new record is created is no longer necessary.

 

Beyond that...if you want the option to display the number at creation time, I'd think through my rambling above a bit...it's a real clean and easy solution.  I will add to it, that doing searching on that scheme play really well in PowerApps - ex.  Filter(data, RequestNumber>=2000000000 && RequestNumber<=2012312359) will give me all the records in the year 2000.  Or, Filter(data, RequestNumber>=2006000000 && RequestNumber<=2006302359) would give me all records in June 2020.  etc...

Two birds, one stone!

 

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

RandyHayes
Super User
Super User

@tagustin2020 

Ah, your column is numeric!  

This will do the trick:

    Coalesce(Parent.Default, Value(Text(Now(), "yymmddhhmm"))) 

I see it was me who forgot the closing paren in the original formula...🤣

 

With Coalesce, all of the parameters must be the same type.  Since your Parent.Default is numeric, we have to convert the Text to numeric for the generated number.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

11 REPLIES 11
RandyHayes
Super User
Super User

@tagustin2020 

A word of caution on this...you can quickly run into issues with concurrency when you try to pre-assign a number that needs to be sequential and unique.

If one user starts to create a new request and gets 10001 and then another user at the same time attempts to create a new request, they will both get 10001.  In fact, without refreshing your sequential list all the time - if you don't then everyone will get 10001.  

This is one (among other) reason that you cannot assign an ID to a new record.  You will get one when you create a record, but not before.

 

So, you have a couple of choices:

1) Skip providing the request number at the time of entry and rely on the ID and a combination of some logic to create the request number you really want.

2) Employ a flow to assign the number after submitted. 

3) Employ some "locking" logic to the sequential number in your list so that it is not used by others.  This will still involve a lot of refreshing of the datasource - very expensive.

 

So, getting the number is relatively easy to do with just a Lookup on the datasource, but given the above...is this a route that you want to take?

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

@RandyHayes 

 

Hello Randy,

 

Thank you for your advice. I found a video tutorial on how to create a custom ID number in Power Automate that is based off of the internal SharePoint ID. It is working, but the number does not immediately populate in the gallery (the rest of the record based on SubmitForm does). I think maybe if I called it from Power Apps and fed the answer back to Power Apps that it would appear more quickly, but I'm not sure how to do that. Can you help me with what steps to add before and after to get it to update real time? Thank you, Teresa

 

RequestIDSS.png

 

Here is the Flow. The full expression is: add(triggerBody()?[‘ID’],10000). Company is what I renamed the Title column. Let me know if you need any additional info.

FlowSS.png

 

RandyHayes
Super User
Super User

@tagustin2020 

So you're going with a combination of #2 and #3.  The first part is to assign the number in flow, but in order to then get that updated in your datasource, you'll need the expensive refresh on the record...and you'll need to get that after the flow completes.

 

<I'm going to ramble here for just a bit...>

I will throw one other thing out there...sequential numbering is a thing of the past!  It is based on the old paper system where each sheet of a form was numbered sequentially.  Somehow that ancient principal has perpetuated even into today, but, and I only mention this to say...stop!  Do you really need a sequential number?  If there is some essential business process that requires it, then you have no choice.  But, if there is not, then why try to continue it?

 

We abandoned sequential numbering in all our systems and apps over a decade ago because it really had not informational value.  What we went with was more of a date-based numbering such as yymmddhhmmss.  Why this? Because it actually provides value.  Unlike a sequential number such as 10030 that provides no real information, this at least provides an exact time of when the artifact was created. If I pick up an item that 10030 on it, I have no idea if this is old or new or what unless I look it up.  If I pick up an item that has 1902071233 on it, I immediately know that this is two years old.

In most cases we only trail down to the seconds in high load apps.  If there is very minimal risk of a person creating two within the same minute, we skip the seconds.  Likewise if there is not chance of two records being created in the same hour, se skip the minutes...and so on.

 

This provides not only valuable information from the unique ID, but it also plays VERY nicely with PowerApps as there is no flow needed nor and issues with refreshing, writing back, etc.  Just submit and the value exists.  Done.

 

Okay...</end rambling here>

 

Now, back to the story...I believe you might have misunderstood my options (and I might have mislead in number 2).  I gave those for the purpose of specifically meeting the requirement of displaying the Sequential ID AT the time the user is creating the item - that seemed to be what you wanted.  And looking back, #2 would not technically have done that (although for some reason that was in my mind).

 

So, that brings me to the conclusion that since you chose flow,  that showing the Sequential ID at the time the user enters the new record is NOT that important.  

In that case I would very much discontinue the use of flow for this.  You will cost your app more performance issues and complexity than is necessary.

 

Instead, simply change your OnSuccess action of your form to the following:

   UpdateIf(yourList, ID=Self.LastSubmit.ID, {'Request Number': Self.LastSubmit.ID + 10000})

 

That will do the equivalent of the flow without the cost.  And your Gallery will immediately reflect it without any further action.

Keeping in mind, that this is based on what you are currently trying, which implies that displaying the Request number to the user before the new record is created is no longer necessary.

 

Beyond that...if you want the option to display the number at creation time, I'd think through my rambling above a bit...it's a real clean and easy solution.  I will add to it, that doing searching on that scheme play really well in PowerApps - ex.  Filter(data, RequestNumber>=2000000000 && RequestNumber<=2012312359) will give me all the records in the year 2000.  Or, Filter(data, RequestNumber>=2006000000 && RequestNumber<=2006302359) would give me all records in June 2020.  etc...

Two birds, one stone!

 

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

@RandyHayes 

 

Hi Randy,

 

Thank you for helping me out. I love how you are always able to come up with simple, smart solutions. That's why I tag you on everything. I deleted my flow and entered the formula you suggested in the OnSuccess property and it worked great. Since Logistics won't see the request until it is created, I really don't think it is necessary to create a number from the very beginning. I have a meeting with them Tuesday so I'll ask again just to verify there isn't some key concept I'm missing. I really like your suggestion to come up with a more meaningful string of numbers that can be filtered by year or month year as I want to build in some reports for them so I would like to learn more about how to do that. What formula(s) would I have to enter to achieve this?

 

Kind regards,

Teresa 

RandyHayes
Super User
Super User

@tagustin2020 

Great!  Always here to spark new ways of doing things for the better.  Sometimes we all get stuck in the weeds of the projects we're on and the phrase "it's hard to see the forest from the trees" really applies.

 

So, for the making of a unique number, I like to just make one up at the time of the New form.  Essentially for the column that will be that value, and usually in a label (or Textinput in view mode - you don't want people to change the number, but you do want it displayed), I would put a formula such as this:

    Coalesce(Parent.Default, Text(Now(), "yymmddhhmm")  (add ss if you expect more than one item to be created in a minute by multiple people)

That should give the unique number.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

@RandyHayes 

 

Hi Randy,

 

I created a new number type column called AltReqNum and pasted it into the Default property of the Value field:

Coalesce(Parent.Default, Text(Now(), "yymmddhhmm")

It is showing errors. Did I add the formula in the wrong place? What do I enter in the OnSuccess of the form, anything?

 

Teresa

AltReqNumSS.png

 

 

RandyHayes
Super User
Super User

@tagustin2020 

What is the error message??  If what you just posted is the exact formula that you have in your app, then there is a syntax error - it needs a closing paren.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

@RandyHayes 

 

Hi Randy,

 

The error is "The function 'Coalesce' has some invalid arguments." I should have mentioned that I tried adding another closing paren before raising the alert.  Thanks, Teresa

 

AltIDErrorSS.png

RandyHayes
Super User
Super User

@tagustin2020 

Ah, your column is numeric!  

This will do the trick:

    Coalesce(Parent.Default, Value(Text(Now(), "yymmddhhmm"))) 

I see it was me who forgot the closing paren in the original formula...🤣

 

With Coalesce, all of the parameters must be the same type.  Since your Parent.Default is numeric, we have to convert the Text to numeric for the generated number.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements

Calling all User Group Leaders and Super Users! Mark Your Calendars for the next Community Ambassador Call on May 9th!

This month's Community Ambassador call is on May 9th at 9a & 3p PDT. Please keep an eye out in your private messages and Teams channels for your invitation. There are lots of exciting updates coming to the Community, and we have some exclusive opportunities to share with you! As always, we'll also review regular updates for User Groups, Super Users, and share general information about what's going on in the Community.     Be sure to register & we hope to see all of you there!

April 2024 Community Newsletter

We're pleased to share the April Community Newsletter, where we highlight the latest news, product releases, upcoming events, and the amazing work of our outstanding Community members.   If you're new to the Community, please make sure to follow the latest News & Announcements and check out the Community on LinkedIn as well! It's the best way to stay up-to-date with all the news from across Microsoft Power Platform and beyond.    COMMUNITY HIGHLIGHTS   Check out the most active community members of the last month! These hardworking members are posting regularly, answering questions, kudos, and providing top solutions in their communities. We are so thankful for each of you--keep up the great work! If you hope to see your name here next month, follow these awesome community members to see what they do!   Power AppsPower AutomateCopilot StudioPower PagesWarrenBelzDeenujialexander2523ragavanrajanLaurensMManishSolankiMattJimisonLucas001AmikcapuanodanilostephenrobertOliverRodriguestimlAndrewJManikandanSFubarmmbr1606VishnuReddy1997theMacResolutionsVishalJhaveriVictorIvanidzejsrandhawahagrua33ikExpiscornovusFGuerrero1PowerAddictgulshankhuranaANBExpiscornovusprathyooSpongYeNived_Nambiardeeksha15795apangelesGochixgrantjenkinsvasu24Mfon   LATEST NEWS Business Applications Launch Event - On Demand In case you missed the Business Applications Launch Event, you can now catch up on all the announcements and watch the entire event on-demand inside Charles Lamanna's latest cloud blog.   This is your one stop shop for all the latest Copilot features across Power Platform and #Dynamics365, including first-hand looks at how companies such as Lenovo, Sonepar, Ford Motor Company, Omnicom and more are using these new capabilities in transformative ways. Click the image below to watch today!     Power Platform Community Conference 2024 is here! It's time to look forward to the next installment of the Power Platform Community Conference, which takes place this year on 18-20th September 2024 at the MGM Grand in Las Vegas!   Come and be inspired by Microsoft senior thought leaders and the engineers behind the #PowerPlatform, with Charles Lamanna, Sangya Singh, Ryan Cunningham, Kim Manis, Nirav Shah, Omar Aftab and Leon Welicki already confirmed to speak. You'll also be able to learn from industry experts and Microsoft MVPs who are dedicated to bridging the gap between humanity and technology. These include the likes of Lisa Crosbie, Victor Dantas, Kristine Kolodziejski, David Yack, Daniel Christian, Miguel Félix, and Mats Necker, with many more to be announced over the coming weeks.   Click here to watch our brand-new sizzle reel for #PPCC24 or click the image below to find out more about registration. See you in Vegas!     Power Up Program Announces New Video-Based Learning Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram. These include a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the image below to find out more!     UPCOMING EVENTS Microsoft Build - Seattle and Online - 21-23rd May 2024 Taking place on 21-23rd May 2024 both online and in Seattle, this is the perfect event to learn more about low code development, creating copilots, cloud platforms, and so much more to help you unleash the power of AI.   There's a serious wealth of talent speaking across the three days, including the likes of Satya Nadella, Amanda K. Silver, Scott Guthrie, Sarah Bird, Charles Lamanna, Miti J., Kevin Scott, Asha Sharma, Rajesh Jha, Arun Ulag, Clay Wesener, and many more.   And don't worry if you can't make it to Seattle, the event will be online and totally free to join. Click the image below to register for #MSBuild today!     European Collab Summit - Germany - 14-16th May 2024 The clock is counting down to the amazing European Collaboration Summit, which takes place in Germany May 14-16, 2024. #CollabSummit2024 is designed to provide cutting-edge insights and best practices into Power Platform, Microsoft 365, Teams, Viva, and so much more. There's a whole host of experts speakers across the three-day event, including the likes of Vesa Juvonen, Laurie Pottmeyer, Dan Holme, Mark Kashman, Dona Sarkar, Gavin Barron, Emily Mancini, Martina Grom, Ahmad Najjar, Liz Sundet, Nikki Chapple, Sara Fennah, Seb Matthews, Tobias Martin, Zoe Wilson, Fabian Williams, and many more.   Click the image below to find out more about #ECS2024 and register today!   Microsoft 365 & Power Platform Conference - Seattle - 3-7th June If you're looking to turbo boost your Power Platform skills this year, why not take a look at everything TechCon365 has to offer at the Seattle Convention Center on June 3-7, 2024.   This amazing 3-day conference (with 2 optional days of workshops) offers over 130 sessions across multiple tracks, alongside 25 workshops presented by Power Platform, Microsoft 365, Microsoft Teams, Viva, Azure, Copilot and AI experts. There's a great array of speakers, including the likes of Nirav Shah, Naomi Moneypenny, Jason Himmelstein, Heather Cook, Karuana Gatimu, Mark Kashman, Michelle Gilbert, Taiki Y., Kristi K., Nate Chamberlain, Julie Koesmarno, Daniel Glenn, Sarah Haase, Marc Windle, Amit Vasu, Joanne C Klein, Agnes Molnar, and many more.   Click the image below for more #Techcon365 intel and register today!   For more events, click the image below to visit the Microsoft Community Days website.    

Tuesday Tip | Update Your Community Profile Today!

It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   We're excited to announce that updating your community profile has never been easier! Keeping your profile up to date is essential for staying connected and engaged with the community.   Check out the following Support Articles with these topics: Accessing Your Community ProfileRetrieving Your Profile URLUpdating Your Community Profile Time ZoneChanging Your Community Profile Picture (Avatar)Setting Your Date Display Preferences Click on your community link for more information: Power Apps, Power Automate, Power Pages, Copilot Studio   Thank you for being an active part of our community. Your contributions make a difference! Best Regards, The Community Management Team

Hear what's next for the Power Up Program

Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram, including a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the link below to sign up today! https://aka.ms/PowerUp  

Tuesday Tip: Community User Groups

It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   As our community family expands each week, we revisit our essential tools, tips, and tricks to ensure you’re well-versed in the community’s pulse. Keep an eye on the News & Announcements for your weekly Tuesday Tips—you never know what you may learn!   Today's Tip: Community User Groups and YOU Being part of, starting, or leading a User Group can have many great benefits for our community members who want to learn, share, and connect with others who are interested in the Microsoft Power Platform and the low-code revolution.   When you are part of a User Group, you discover amazing connections, learn incredible things, and build your skills. Some User Groups work in the virtual space, but many meet in physical locations, meaning you have several options when it comes to building community with people who are learning and growing together!   Some of the benefits of our Community User Groups are: Network with like-minded peers and product experts, and get in front of potential employers and clients.Learn from industry experts and influencers and make your own solutions more successful.Access exclusive community space, resources, tools, and support from Microsoft.Collaborate on projects, share best practices, and empower each other. These are just a few of the reasons why our community members love their User Groups. Don't wait. Get involved with (or maybe even start) a User Group today--just follow the tips below to get started.For current or new User Group leaders, all the information you need is here: User Group Leader Get Started GuideOnce you've kicked off your User Group, find the resources you need:  Community User Group ExperienceHave questions about our Community User Groups? Let us know! We are here to help you!

Super User of the Month | Ahmed Salih

We're thrilled to announce that Ahmed Salih is our Super User of the Month for April 2024. Ahmed has been one of our most active Super Users this year--in fact, he kicked off the year in our Community with this great video reminder of why being a Super User has been so important to him!   Ahmed is the Senior Power Platform Architect at Saint Jude's Children's Research Hospital in Memphis. He's been a Super User for two seasons and is also a Microsoft MVP! He's celebrating his 3rd year being active in the Community--and he's received more than 500 kudos while authoring nearly 300 solutions. Ahmed's contributions to the Super User in Training program has been invaluable, with his most recent session with SUIT highlighting an incredible amount of best practices and tips that have helped him achieve his success.   Ahmed's infectious enthusiasm and boundless energy are a key reason why so many Community members appreciate how he brings his personality--and expertise--to every interaction. With all the solutions he provides, his willingness to help the Community learn more about Power Platform, and his sheer joy in life, we are pleased to celebrate Ahmed and all his contributions! You can find him in the Community and on LinkedIn. Congratulations, Ahmed--thank you for being a SUPER user!  

Top Solution Authors
Top Kudoed Authors
Users online (5,165)