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

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

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.

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.

Users online (5,120)