cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ShadowTech
Post Prodigy
Post Prodigy

How to auto populate title field in gallery tied to SharePoint list.

Hello,

 

Scenario:

 

I want to auto populate the title field in a new "edit" form The source is a SharePoint list. I want this number to increment ever time the new submit form is navigated to.

 

Title number text looks like this:     Job-000001

 

Thanks in advance.

1 ACCEPTED SOLUTION

Accepted Solutions
Eelman
Super User
Super User

@ShadowTech 

Firstly, I'd create a Helper column in SharePoint that holds the numeric part of your Job number and set it as Type Number.

 

You can then get the last / highest number in your list using

 

Set(vLastJobNum, First(Sort(yourListName, helperColumnName, Descending)).helperColumnName)

 

Note: this may throw a Delegation warning but you can ignore this because you are only getting one record.

 

Then, on Navigation to your Form screen (or the OnVisible property) use this:

 

Set(vNewJobNum, Concatenate("Job-", Text(Value(vLastJobNum)+1, "00000")))

 

 

Then inside your Form on the Title datacard use the variable vNewJobNum as the Default value/property.

 

Depending on your App's flow ie how it functions, you may need to run both of the above formulas at the same time, it just depends really.

 

EDIT: I forgot to mention, you will need to update the helperColumn somehow. My suggestion would be to add the DataCard for the HelperColumn into your Form, set it's Default to Value(vLastJobNum)+1, then set it's Visibile to false. Then, when your Form is Submitted, it will update with the latest Numeric value of your Job Number.

View solution in original post

7 REPLIES 7
Eelman
Super User
Super User

@ShadowTech 

Firstly, I'd create a Helper column in SharePoint that holds the numeric part of your Job number and set it as Type Number.

 

You can then get the last / highest number in your list using

 

Set(vLastJobNum, First(Sort(yourListName, helperColumnName, Descending)).helperColumnName)

 

Note: this may throw a Delegation warning but you can ignore this because you are only getting one record.

 

Then, on Navigation to your Form screen (or the OnVisible property) use this:

 

Set(vNewJobNum, Concatenate("Job-", Text(Value(vLastJobNum)+1, "00000")))

 

 

Then inside your Form on the Title datacard use the variable vNewJobNum as the Default value/property.

 

Depending on your App's flow ie how it functions, you may need to run both of the above formulas at the same time, it just depends really.

 

EDIT: I forgot to mention, you will need to update the helperColumn somehow. My suggestion would be to add the DataCard for the HelperColumn into your Form, set it's Default to Value(vLastJobNum)+1, then set it's Visibile to false. Then, when your Form is Submitted, it will update with the latest Numeric value of your Job Number.

@Eelman 

 

Where am I inputting this?

 

Set(vLastJobNum, First(Sort(yourListName, helperColumnName, Descending)).helperColumnName)

 

And can you please explain about running them at the same time?

 

Thanks again for your help.

@ShadowTech 

re: Where am I inputting this?

That depends. Say you have a Gallery where users can see options to select that take them to your Form screen, you can add this code before the Navigate() function ... or ... you can use it in the OnVisible property of your Form screen.

 

If you don't want to do either of these, you can just have a button/icon/label and set the OnSelect property to this code. It really depends on the flow of your app.

 

By 'Running at the same time' I mean join the code together. For example, if you decided to place the code before your Navigate() function (my first option above) then you would add both code blocks before the Navigate function ie 'Run them together', if that makes sense?

@ShadowTech 

Just checking in to see if you managed to solve your issue? I'm happy to help further if you are still stuck, just let me know.

@Eelman 

 

So It populates the field but with the value that's in the helper column. A change it a bit around:

 

Title number increments : JOB-900001, JOB-900002, JOB-900003...

 

In the helper column which is a number type I put 90000. It populates the Title field but only with the number in that field...90000.

 

HomeScreen button that navigates to the new form screen:  

 

Set(vLastJobNum, First(Sort(ARSC, AutoPopHelper, Descending)).AutoPopHelper); NewForm(Form2_2);Navigate(SubmitNewScreen)

 

OnVisible (New form screen):

 

Set(vNewJobNum, Concatenate("JOB-", Text(Value(vLastJobNum)+1, "[$-en-US]90000")))

 

Thanks in advance.

@Eelman 

 

Its only incrementing what's in the helper column not what's in the title column. So the number never changes when navigating to the new form screen.

@Eelman 

 

Figured it out. Forgot to add the variable to the helper column. Works now.

 

Thanks for your help!

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Users online (1,349)