cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
bassman99
Helper I
Helper I

Updating a Data Card from a Button on Canvas app: Why so hard?

I'm trying to update a data-card on an Edit Screen (Canvas app), from the "OnSelect" of a button.  I would think this trivial, but no...

...apparently the .Text field is read-only.

 

I've seen work-arounds, like A) creating a context variable, and using it as the default property or the B) Patch function, but both seem difficult for something so basic/trivial.

 

Am I missing something?

1 ACCEPTED SOLUTION

Accepted Solutions
Pstork1
Dual Super User
Dual Super User

What you are missing is that Power Apps is a declarative environment, not a procedural one.  So you can't directly change the properties of any controls at runtime.  That's true for the .Text property you want to change and its also true for properties like .color or .visible.  But the properties are always looking for changes in the environment and updating themselves based on the formulas that set their value.  So as you have seen you can change the value of a variable (either context or global) in an OnSelect and then have either the default property or the text property itself set based on that variable value.  The one problem you will run into is that as soon as someone overwrites that value the new value will take precedence and it will ignore changes to the variable unless you also reset the control.  It can be confusing if you are used to working with a procedural language.  But it is the way its designed to work.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Join me at 365 and PWR EduCon in Chicago
EduCon Chicago 2022

View solution in original post

2 REPLIES 2
Pstork1
Dual Super User
Dual Super User

What you are missing is that Power Apps is a declarative environment, not a procedural one.  So you can't directly change the properties of any controls at runtime.  That's true for the .Text property you want to change and its also true for properties like .color or .visible.  But the properties are always looking for changes in the environment and updating themselves based on the formulas that set their value.  So as you have seen you can change the value of a variable (either context or global) in an OnSelect and then have either the default property or the text property itself set based on that variable value.  The one problem you will run into is that as soon as someone overwrites that value the new value will take precedence and it will ignore changes to the variable unless you also reset the control.  It can be confusing if you are used to working with a procedural language.  But it is the way its designed to work.



-------------------------------------------------------------------------
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Join me at 365 and PWR EduCon in Chicago
EduCon Chicago 2022

bassman99
Helper I
Helper I

MUCH appreciated!

Helpful resources

Announcements
Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Government Carousel

New forum: GCC, GCCH, DoD - Federal App Makers (FAM)

In response to the unique and evolving requirements of the United States public sector, Microsoft has created Power Apps US Government.

Users online (1,818)