cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Cjlast
New Member

Autopopulate a Text Input field of an Item in a Gallery

Hi,

 

I created a Power App that lists records of an Entity (Invoices). I also added a Text Input (PayAmount) control and a button (Pay All) in the Gallery where I added that Entity. I want to populate PayAmount with the value of the "Outstanding Balance" whenever I click Pay All. I tried using a Variable which will be set once I click Pay All and I used that variable as the "Default" of the PayAmount. Unfortunately when I click Pay All, it updates the PayAmount of all the Items in the list (See screenshot). Is there a way for the Pay All to only update the PayAmount of the Item on which I clicked it? Thank you.

 

Capture.PNG

1 ACCEPTED SOLUTION

Accepted Solutions
Drrickryp
Super User
Super User

@Cjlast 

This one wasn't as easy as I thought it would be.  In my example, I used a checkbox instead of a button to simplify.  The OnCheck and OnUncheck properties were

 

UpdateContext(
              {var:If(
                      CountIf(
                               Gallery1.AllItems,Checkbox1.Value=true
                        )>0,true,false
                      )
               }
)

 

The Default property of the textbox was 

 

If(
   Checkbox1.Value,ThisItem.Address,Blank()
)

 

In my example, I used City but you would use ThisItem.OutstandingBalance.  BTW it gave me a headache just getting this far.  I will leave it to you to figure out how to use a button instead of a checkbox.

_3.jpg

View solution in original post

10 REPLIES 10
Drrickryp
Super User
Super User

Patch(Invoices,ThisItem, {PayAmount:Textinput1.Text*1})

 

*1 converts text to number.

Hi @Drrickryp ,

 

I'm encountering this error. Is it correct that I put it in the OnSelect of the button?

 

Cjlast_0-1612479872456.png

 

Drrickryp
Super User
Super User

Yes. You need to have the name of the textinput box in the formula. PowerApps is not recognizing the name of your control. If that doesn't work try leaving off the*1. Your payamount field may be text. I had assumed it was a number.

I think it's looking for the PayAmount in the columns/fields of my Invoice Table, but the PayAmount is a Text Input that I only added in the Power App Gallery.

Drrickryp
Super User
Super User

Wow @Cjlast , now you got me confused. If you aren't saving the data, what are you trying to do here ?

Oh sorry. There's another button that will collect the value of that Text Input. What the user would just want is the ability to automatically populate the Text Input with the Outstanding Balance Amount instead of typing the Amount. 

 

Here's the overall look:

 

Cjlast_0-1612481683482.png

 

@Cjlast 

I was overthinking the problem,

Ok, you can just put in the Default property of the TextInput Box, ThisItem.OutstandingBalance, Assuming that is the name of the field that contains the outstanding balance for that record.

I tried what you suggested but it only defaults the value of the Text Input with the value of the Outstanding Balance. What I would want to achieve is for the Text Input to only be populated when I click the Pay All button and on the specific item only where I clicked the Pay all button.

Drrickryp
Super User
Super User

@Cjlast 

This one wasn't as easy as I thought it would be.  In my example, I used a checkbox instead of a button to simplify.  The OnCheck and OnUncheck properties were

 

UpdateContext(
              {var:If(
                      CountIf(
                               Gallery1.AllItems,Checkbox1.Value=true
                        )>0,true,false
                      )
               }
)

 

The Default property of the textbox was 

 

If(
   Checkbox1.Value,ThisItem.Address,Blank()
)

 

In my example, I used City but you would use ThisItem.OutstandingBalance.  BTW it gave me a headache just getting this far.  I will leave it to you to figure out how to use a button instead of a checkbox.

_3.jpg

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,953)