cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
Helper I
Helper I

Re: Auto Generated Case number

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

Highlighted
Super User
Super User

Re: Auto Generated Case number

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.

Proud to be a Super User!

Regards,
KrishnaV
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

Highlighted
Super User
Super User

Re: Auto Generated Case number

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
Highlighted
Helper I
Helper I

Re: Auto Generated Case number

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

Highlighted
Super User
Super User

Re: Auto Generated Case number

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.

Proud to be a Super User!

Regards,
KrishnaV
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

Highlighted
Super User
Super User

Re: Auto Generated Case number

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

Helpful resources

Announcements
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Users online (4,880)