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

I want to create an auto icremental number in Power apps

Hi All 

 

I would like some assitance on this ,I want to create an Incremental Incident number everytime I save a record on my app .

I have different forms as well so I want to uniquely identify them per form e.g  Injury on duty incident can be IND-0000000001 for that specific form ,Health and safety can be HS-0000000002 for that form  ,crime incident can be CI-0000000003 etc.

Even just an icremental number each time a record  is created would be greatINC-00000000001-2-3-4 etc. I have a work around but I want to change it.I have a function thats  returns the year ,month ,date , initials of the user and actual time so that it always generates random numbers please see attached .

Any new ideas will be welcome .

 

Regards 

 

Rodney

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: I want to create an auto icremental number in Power apps

Hi @rmaziwis ,

Do you want to generate autonumber based on different condition?

If so, try this formula:

If(condition1,Patch(tablename,...,
{IDfield:"IND-"&Text(Value(
Right(
Last(
SortByColumns(
Right(ShowColumns(Filter(tablename,"IND" in "IDfield"), "IDfield"),10),
                                                                     "IDfield"
                                                                    )
                                                      ).IDfield,8
                                                  )         //return the max number of IND IDfield
                                          )+1),"##########")
                     }
                    ),

condition2,Patch(tablename,...,
                    {IDfield:"HS-"&Text(Value(Right(Last(SortByColumns(Right(ShowColumns(Filter(tablename,"HS" in "IDfield"), "IDfield"),10),"IDfield")).IDfield,8))+1),"##########")}),

condition3,Patch(tablename,...,
                    {IDfield:"CI-"&Text(Value(Right(Last(SortByColumns(Right(ShowColumns(Filter(tablename,"CI" in "IDfield"), "IDfield"),10),"IDfield")).IDfield,8))+1),"##########")})
)

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
3 REPLIES 3
Super User
Super User

Re: I want to create an auto icremental number in Power apps

Hi @rmaziwis 

 

Using auto generated ID will require you to query your data source, get the latest ID and accordingly set it

This may run into concurrency issues and can be problematic

 

the Now() function will return the current date and time and has least probability of same number being generated

Text(Now(),"[$-en-US]ddmmyyyyhhmmss") will be unqiue

 

If you want incremental counters, then you could trigger a Flow once item is added to SharePoint and then use the item ID (internal ID Column - always unqiue) and then accordingly update the number field

OR

You could just use the SharePoint ID Column which is numeric and auto updates

 

Regards,

Reza Dorrani

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Highlighted
rmaziwis
Level: Powered On

Re: I want to create an auto icremental number in Power apps

Thanks I will try that please note in my currect solution I already use the Text now function .I will try the flow option and Let you know thank you .

 

 

Regards 

Community Support Team
Community Support Team

Re: I want to create an auto icremental number in Power apps

Hi @rmaziwis ,

Do you want to generate autonumber based on different condition?

If so, try this formula:

If(condition1,Patch(tablename,...,
{IDfield:"IND-"&Text(Value(
Right(
Last(
SortByColumns(
Right(ShowColumns(Filter(tablename,"IND" in "IDfield"), "IDfield"),10),
                                                                     "IDfield"
                                                                    )
                                                      ).IDfield,8
                                                  )         //return the max number of IND IDfield
                                          )+1),"##########")
                     }
                    ),

condition2,Patch(tablename,...,
                    {IDfield:"HS-"&Text(Value(Right(Last(SortByColumns(Right(ShowColumns(Filter(tablename,"HS" in "IDfield"), "IDfield"),10),"IDfield")).IDfield,8))+1),"##########")}),

condition3,Patch(tablename,...,
                    {IDfield:"CI-"&Text(Value(Right(Last(SortByColumns(Right(ShowColumns(Filter(tablename,"CI" in "IDfield"), "IDfield"),10),"IDfield")).IDfield,8))+1),"##########")})
)

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
firstImage

PowerApps Monthly Community Call!

Join us next Wednesday for our Demo Extravaganza, October 16, 2019 8am PDT.

firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

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

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 363 members 4,246 guests
Please welcome our newest community members: