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

Auto Generated Case number

Hi All 

 

Iam kindly asking for your assistance Iam creating a Covid-19 application for our company .

 

When a Covid-19 case is logged that someone has to go for testing a case number must be created .

 

I would like it to generate an incremental CASE number but it must create this by using the branch the user is capturing for  the Covid 19 case is for for example if it is cape town branch I want to have a format CPT-0000001

and if its Pretoria it can have PT-000001 .

 

I ask the user to do branch selection on the form but Iam not sure how I can link this ,

 

I have attached the form and branches ,I will rename the incident reference to COVID-19 CASE NUMBER and the branches are shown as well any ideas will be welcome please .

Form.JPGBranches.JPG 

 

 

 

 

3 ACCEPTED SOLUTIONS

Accepted Solutions
goDynamic
Helper I
Helper I

Hi,

 

You can create an entiy/table to hold the config values (1 record for each branch) eg. prefix (CPT), current number(000001), etc for each branch. When the user selects a branch, query the configuration entity/table for right branch and use the prefix and increment the number from current number. Write back the incremented number to the corresponding config setting record.

 

Thanks

 

View solution in original post

KrishnaV
Community Champion
Community Champion

Hi @rmaziwis ,

 

See if this helps you:

 

Clear(colNumberedInvoices);
ForAll(Invoices, 
       Collect(colNumberedInvoices,
               Last(FirstN(AddColumns(Invoices,
                                "RowNumber",
                                CountRows(colNumberedInvoices)+1
                           ), 
                           CountRows(colNumberedInvoices)+1
                    )
               )    
       )
)

 

The complete blog is: http://powerappsguide.com/blog/post/generating-row-numbers

 

By the way, I really like your design all the best on your app development.

 

 

Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

 

Regards,
Krishna


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
KrishnaV
Business Applications MVP, Microsoft Certified Trainer
Twitter | Linkedin | YouTube | GitHub
If this post helps you give a and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.

View solution in original post

Drrickryp
Super User
Super User

Hi @rmaziwis 

Assuming you have a SharePoint list that has an autonumber ID field.  To obtain a number you could have the following formula:

 

 

Concatenate(
   ddLocation.Selected.Value,"-", 
        Text(
         First( 
            Sort(
              Filter(
                  yourlist, Location = ddlocation.Selected.Value
                     ),
                   ID,Descending
                  )
                ).ID+1,"00000"
               )
              )
                         

 

 

Concatenate(ddLocation.Selected.Value,,"-",First(Sort(Filter(yourlist),Location=ddlocation.Selected.Value,),ID,Descending)).ID+1)

The reason for not using Last() or Max() in the formula is that these functions are not delegatable and after the first 2000 records, they will become inaccurate.  First(Sort(xxx,ID, descending)).ID  will be accurate no matter how many records are in the list. 

If the ddLocation control references a list with a full name and abbreviation for the region, you would use the abbreviation in the Concatenate function instead of the value. 

View solution in original post

3 REPLIES 3
goDynamic
Helper I
Helper I

Hi,

 

You can create an entiy/table to hold the config values (1 record for each branch) eg. prefix (CPT), current number(000001), etc for each branch. When the user selects a branch, query the configuration entity/table for right branch and use the prefix and increment the number from current number. Write back the incremented number to the corresponding config setting record.

 

Thanks

 

KrishnaV
Community Champion
Community Champion

Hi @rmaziwis ,

 

See if this helps you:

 

Clear(colNumberedInvoices);
ForAll(Invoices, 
       Collect(colNumberedInvoices,
               Last(FirstN(AddColumns(Invoices,
                                "RowNumber",
                                CountRows(colNumberedInvoices)+1
                           ), 
                           CountRows(colNumberedInvoices)+1
                    )
               )    
       )
)

 

The complete blog is: http://powerappsguide.com/blog/post/generating-row-numbers

 

By the way, I really like your design all the best on your app development.

 

 

Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

 

Regards,
Krishna


I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

Regards,
KrishnaV
Business Applications MVP, Microsoft Certified Trainer
Twitter | Linkedin | YouTube | GitHub
If this post helps you give a and if it solved your issue consider Accept it as the solution to help the other members / new members of the community.
Drrickryp
Super User
Super User

Hi @rmaziwis 

Assuming you have a SharePoint list that has an autonumber ID field.  To obtain a number you could have the following formula:

 

 

Concatenate(
   ddLocation.Selected.Value,"-", 
        Text(
         First( 
            Sort(
              Filter(
                  yourlist, Location = ddlocation.Selected.Value
                     ),
                   ID,Descending
                  )
                ).ID+1,"00000"
               )
              )
                         

 

 

Concatenate(ddLocation.Selected.Value,,"-",First(Sort(Filter(yourlist),Location=ddlocation.Selected.Value,),ID,Descending)).ID+1)

The reason for not using Last() or Max() in the formula is that these functions are not delegatable and after the first 2000 records, they will become inaccurate.  First(Sort(xxx,ID, descending)).ID  will be accurate no matter how many records are in the list. 

If the ddLocation control references a list with a full name and abbreviation for the region, you would use the abbreviation in the Concatenate function instead of the value. 

Helpful resources

Announcements
October Events

Mark Your Calendars

So many events that are happening this month - don't miss out!

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.

Top Solution Authors
Top Kudoed Authors
Users online (3,838)