cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
RussellGove
Level 8

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
Highlighted
tianaranjo
Level 8

Re: How to set the value of a datacard in a form

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
Highlighted
tianaranjo
Level 8

Re: How to set the value of a datacard in a form

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

Re: How to set the value of a datacard in a form

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 Smiley Happy

 

 

Hope it helps.

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Demo Extravaganza Championship Voting Open

Voting Ends: October 30, 2019!

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

Top Kudoed Authors
Users Online
Currently online: 179 members 4,555 guests
Please welcome our newest community members: