cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
webdevguy
Helper II
Helper II

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

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

try replacing the value through onscreenvisible

eg: textbox1.value=0 in the onscreenvisible parameter

dinusc
Microsoft
Microsoft

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})

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.

Have you tried the binding method?

Trying to figure it out now. 

 

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

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


@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. 

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

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
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.

Carousel_PP_768x460_Wave2 (1).png

2022 Release Wave 2 Plan

Power Platform release plan for the 2022 release wave 2 describes all new features releasing from October 2022 through March 2023.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Top Solution Authors
Users online (3,007)