cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Oskarkuus
Post Prodigy
Post Prodigy

How to set variable to a datasource column?

I have a datasource that is a sharepoint list.

In my datasource i have a column called "xtype" and "xtype2"

 

I want to to push a button and update a textinput field on my app so that the datasource to the textinput changes.

 

For example

If user press button1 it sets textinput1 to have xtype in it´s Text option.

If user press button2 it sets textinput1 to have xtype2 in it´s Text option.

 

I have tried setting a variable on the Onselect on each button.

Likse this:

Set(buttonvar;xtype)

Set(buttonvar;xtype2)

 

Then put buttonvar in the textinput1 field

But i get error that xtype and xtype2 does not exist.

But they do...

 

What am i doing wrong?

1 ACCEPTED SOLUTION

Accepted Solutions

@Oskarkuus 

Let me see if I understand you properly...

You have a Gallery - not an EditForm.  Outside of the Gallery you have a 2 Buttons.  One (let's call) "xtype" and the other "xtype2".  If the user presses "xtype" you want the values in the textinput controls that you have in your Gallery to all change to reflect the xtype column of the item in the gallery.  If the user presses "xtype2" you want to have all the textinput controls in the gallery change to reflect the xtype2 column of the item.

 

If that is the case, then you can take this approach:

On the OnSelect of the xtype button, set this formula :  UpdateContext({showXtype2: false})

On the OnSelect of the xtype2 button, set this formula:  UpdateContext({showXtype2: true})

On the TextInput control in your Gallery, set the Default property to this formula:  If(showXtype2, ThisItem.xtype2, ThisItem.xtype)

 

That will give you what I described above.  

Let's see how that works for you.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

3 REPLIES 3
RandyHayes
Super User
Super User

@Oskarkuus 

Firstly, I am assuming you are working in an EditForm and thus on just one record. AND, that your button is within your Form.  This response is predicated on that assumption.

What you can do is adjust your formulas to the following (on their respective buttons):

Set(buttonvar; ThisItem.xtype)
Set(buttonvar; ThisItem.xtype2)

And, of course, the default value for your textinput would be buttonvar.

 

If the above assumptions are not the case, then post back and we can punt at another option.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

I tried those codes but they do not work.

 

I get the same error.

 

I am working in an gallery.

I want to change the gallery labels when i press a button outside of the gallery.

so if i press button1 set textinput1 to xtype (column)

if i press button2 set textinput1 to xtype2(column)

@Oskarkuus 

Let me see if I understand you properly...

You have a Gallery - not an EditForm.  Outside of the Gallery you have a 2 Buttons.  One (let's call) "xtype" and the other "xtype2".  If the user presses "xtype" you want the values in the textinput controls that you have in your Gallery to all change to reflect the xtype column of the item in the gallery.  If the user presses "xtype2" you want to have all the textinput controls in the gallery change to reflect the xtype2 column of the item.

 

If that is the case, then you can take this approach:

On the OnSelect of the xtype button, set this formula :  UpdateContext({showXtype2: false})

On the OnSelect of the xtype2 button, set this formula:  UpdateContext({showXtype2: true})

On the TextInput control in your Gallery, set the Default property to this formula:  If(showXtype2, ThisItem.xtype2, ThisItem.xtype)

 

That will give you what I described above.  

Let's see how that works for you.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

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,872)