cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
webdevguy
Level: Powered On

Trouble with default in textbox

I'm creating an inventory manager (excel backend). I have a textbox on my edit screen who's default is supposed to be 0 every time they enter the edit screen. It's not linked to any data field, just used for calculations. (Red arrow is pointing to it.)

 

So, basically when I put a value in this text field, automatically this value is added to the current qty and the new number is displayed (in green). (I'm basically saving the green number to the excel backend.)

 

Here's the problem: When I go in the screen the very first time it's '0'. But, after I put in a number, save/exit the form, then re-enter the form the value I typed in is retained. How do I get it to reset each time?

 

Screenshot_5_3_18__7_31_PM.jpg

1 ACCEPTED SOLUTION

Accepted Solutions
CMee
Level: Powered On

Re: Trouble with default in textbox

For a control in a form to get back to the default value the form needs to be reset using ResetForm.

 

See if the following works:

TextInput.Default = 0

 

Then on any control where you are navigating away from that screen add:

 

;ResetForm(EditScreen1)

including the semicolon.

 

It looks like you are using the template that is automatically generated when you select a data source, so you might see that ResetForm is already there on the X icon.

View solution in original post

13 REPLIES 13
aearioweu
Level: Powered On

Re: Trouble with default in textbox

try replacing the value through onscreenvisible

eg: textbox1.value=0 in the onscreenvisible parameter

Microsoft dinusc
Microsoft

Re: Trouble with default in textbox

You can bind the Text input control to a context variable (TextInput1.Deafult = vvv) and then reset it when needed. Is your form in a separate screen? If so then you can Screen2.OnVisible=UpdateContext({vvv:0})

webdevguy
Level: Powered On

Re: Trouble with default in textbox

I went to the OnVisible property of my edit screen and put in

 

DataCardValue7.text = "0"

 

but it didn't show work. It still showed the former value.

Microsoft dinusc
Microsoft

Re: Trouble with default in textbox

Have you tried the binding method?

webdevguy
Level: Powered On

Re: Trouble with default in textbox

Trying to figure it out now. 

 

I'm from a .NET background so this is kind of confusing. haha

Highlighted
aearioweu
Level: Powered On

Re: Trouble with default in textbox

Another way you can try is to create an updatecontext to run in onvisible

 

UpdateContext({textbox1value: "0"}) -onvisible

in the default of textbox1, textbox1value

 

you can even add a new updatecontext to the onselect of the textbox so it clears the value when selected.

 

onselect- UpdateContext({textbox1value: ""})

 

 

webdevguy
Level: Powered On

Re: Trouble with default in textbox

I


@aearioweu wrote:

Another way you can try is to create an updatecontext to run in onvisible

 

UpdateContext({textbox1value: "0"}) -onvisible

in the default of textbox1, textbox1value

 

you can even add a new updatecontext to the onselect of the textbox so it clears the value when selected.

 

onselect- UpdateContext({textbox1value: ""})

 

 


I see what you're recommending and I tried it but it still didn't work.

 

On my edit screen's OnVisible I put: UpdateContext({QtyDefault:""})

 

Then in my actual textbox's Default action I put: QtyDefault

 

It works the first time. But after I enter a value, save, and re-enter the form the new textbox's value is still preserved. 

aearioweu
Level: Powered On

Re: Trouble with default in textbox

Are you changing screens when you save? If not this wont work.

 

You'll need to add the updatecontext command after you press the save button

webdevguy
Level: Powered On

Re: Trouble with default in textbox

I have 2 screens: A main screen, which is the list of the main items and an edit page.

 

After I make an edit on the edit page I hit "save" and it goes back to the main screen.

 

The problem is when I try to edit another record. The last "qty" is there.

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 (Last 30 Days)
Users online (4,511)