cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rmaziwis
Resolver I
Resolver I

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

 

 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions

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 

View solution in original post

v-yutliu-msft
Community Support
Community Support

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.

View solution in original post

3 REPLIES 3
RezaDorrani
Dual Super User
Dual Super User

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

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 

v-yutliu-msft
Community Support
Community Support

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
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Users online (3,003)