cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
RussellGove
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
tianaranjo
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
tianaranjo
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)

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
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 (3,081)