cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Increment a number in a text box on button press

I have a unique ID which is in a read-only text box input. I wish to have this number increment by one each time the proceed button is pressed. So far, I have only been able to use solutions that must connect to my SharePoint database. I wish to have this number independent and simply increment by one, then write this new number to a SharePoint list.

 

Here's my current attempt: 

Inside btnProceed: 

Set(
varIncrement,
"1"
);
varIncrement + 1

 

varIncrement is inside the text input Default property.

 

Any help would be appreciated.

 

Thanks!

6 REPLIES 6
Dual Super User
Dual Super User

Re: Increment a number in a text box on button press

You are close, but you have to seperate the Set from the increment.  

1) Add the Set(varIncrement,1) to the OnStart method of the App

2) Add Set(varIncrement, varIncrement + 1) to the BtnProceed OnSelect event

3) Set the Default property of the Textbox to varIncrement



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Anonymous
Not applicable

Re: Increment a number in a text box on button press

Thank you for the response, very helpful!

 

With your solution, the number still does not increment by one every time the Proceed button is pressed. Have you any idea as to why? I am currently trying to figure it out. 

 

Thanks for the help.

Dual Super User
Dual Super User

Re: Increment a number in a text box on button press

Not sure what is happening in your version.  I built it in my environment just as described and it worked fine.  Do you have other commands being issued by the Proceed button?



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Anonymous
Not applicable

Re: Increment a number in a text box on button press

 Yes, it is within a large if statement that error handles an entire submit form. See below the if statement in question. I may have the order wrong in places, but the logic behind the statement looks fine. 

 

If(
Start_3.SelectedDate > Now(),
Notify("Start date can not be later than today."),
End_3.SelectedDate > Now(),
Notify("End date can not be later than today."),
Start_3.SelectedDate > End_3.SelectedDate,
Notify("Start date must be before end date."),
IsBlank(txtAffectedSystem_3.Text),
Notify("Please enter an affected system."),
IsBlank(txtComments_3.Text),
Notify("Please enter a comment."),
Value(txtUpdatedTotalHours_2.Text) > difference,
Notify("Total hours can not exceed the total hours between the selected dates. Please choose a correct total hours option."),
Set(
varIncrementNew,
varIncrement + 1
),
SubmitForm(AddForm),
UpdateContext({varEditPopUp: true}),
Refresh(DowntimeDB),
ResetForm(AddForm)
);

Dual Super User
Dual Super User

Re: Increment a number in a text box on button press

It looks to me like your parentheses are off in your IF statement.  The way I read it in an editor the set will only fire if 

Value(txtUpdatedTotalHours_2.Text) <= difference.  I also think a lot of your comma's in that If statement should be semicolons. It would read more cleanly if you seperated out the individual IF statements and used them to set a variable, then acted on the value of that variable to do your set and submit at the end.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Anonymous
Not applicable

Re: Increment a number in a text box on button press

Thank you for the help! I have manipulated the if statement and reorganized certain conditions. The record number now increments correctly. I have just discovered a new issue with this unique ID. In the OnStart section of the app, the variable varIncrement must increment from the previous record number stored in the Database. So rather than Set(varIncrement, 1) it must be Set(varIncrement, [last record number stored]).

 

I will look into this, but thank you for your help!

 

All the best.

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

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

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 337 members 5,897 guests
Please welcome our newest community members: