cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Kudo Kingpin
Kudo Kingpin

How to set the value of a datacard in a form

Hi,

I have a powerapp generated from a sharepoint list.

 

The EditForm has a datacard called DataCardApproval. DatacardApproval has a TextInputBox called dataCardValueappoval. 

 

I have two icons on the screen , When i click each of the Icons I want it to update the value in dataCardValue,

 

I have this in the onSelect for one of the icons: DataCardValueApproval.Text="0";

 

The idea is to let the user click the icon rather than needing to type in the "0", and have it save back to sharepoint when the  user saves from the edit screen.

 

Wit the code above, when the user clicks the icon nothing happens. The text in DataCardValueApproval remains unchantged.

 

Any Ideas?

1 ACCEPTED SOLUTION

Accepted Solutions
Continued Contributor
Continued Contributor

Set your icon to a context variable - Icon - OnSelect - UpdateContext({IconChecked: true})

Set your data card Default text - If(IconChecked, "0", Parent.Default)

View solution in original post

2 REPLIES 2
Continued Contributor
Continued Contributor

Set your icon to a context variable - Icon - OnSelect - UpdateContext({IconChecked: true})

Set your data card Default text - If(IconChecked, "0", Parent.Default)

View solution in original post

Anonymous
Not applicable

Hi @RussellGove,

you can achieve this also by setting new variable by clicking on the icon and then set set the value of variable to the value attribute of the datacard.

 

So first of all go to the settings of the Icon to the attribute OnSelect and write this code. (Var = variable name)

Set(Var,Var+1)

Then go to the DataCardValueXY and find the attribute Default

 

Default=Var

 

So after you do this the default value of DataCardValueXY will be Var+1 each time you press the Icon. So you have to limit it by customizing the code a bit.

Set(Var,If(Var="1",Var-1,Var+1))

 

That works as I expereinced it.

 

The other thing is, that the default value could be faulty as it doesnt update properly each time from my experience. So in this case you would need to use another action to update the DataCardValueXY.

 

Something like OnSelect property of icon

Set(Var,If(Var="1",Var-1,Var+1));DataCardValueXY.Text=Var

but i have never tested this scenario so no promises of functionality 🙂

 

 

Hope it helps.

Helpful resources

Announcements
secondImage

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Power Apps Community Call

Power Apps Community Call: February

Did you miss the call? Check out the Power Apps Community Call here.

New Power Super Users

Congratulations!

We are excited to announce the Power Apps Super Users!

New Badges

New Solution Badges!

Check out our new profile badges recognizing authored solutions!

Top Kudoed Authors
Users online (37,918)