cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
pathum
Helper II
Helper II

Problem with UpdateContext and Set ?

Hi All,

 

Please help i just started to using Power Apps, I'm trying to set a variable default value on Screen OnVisible and access show it on Screen through label, I have used both UpdateContext and Set method to do it. but i don't see the default variable in the label's Text value. 

 

It only appear after action performed on the variable, on button click event and assign different value to the variable using UpdateContext but how can i access the default value ?

 

What i'm doing wrong here ?

 

Thanks

 

1 ACCEPTED SOLUTION

Accepted Solutions
Pstork1
Dual Super User
Dual Super User

UpdateContext and Set create two different kinds of variables.  You can't use them with the same variable name.  But to do what you describe try this.

1) in the OnVisible property of the screen enter the following function.

Set(myVar, "Test Label")

2) add a label to that screen and set the Text property to the following

myVar

Start your app on a different screen and navigate to the screen where you put the label.  You should see the text.



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

4 REPLIES 4
Pstork1
Dual Super User
Dual Super User

UpdateContext and Set create two different kinds of variables.  You can't use them with the same variable name.  But to do what you describe try this.

1) in the OnVisible property of the screen enter the following function.

Set(myVar, "Test Label")

2) add a label to that screen and set the Text property to the following

myVar

Start your app on a different screen and navigate to the screen where you put the label.  You should see the text.



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

C-Papa
Super User
Super User

hi, it might be best to post your code see we can see what is happening, but the below should work:

Screen OnVisible: Set(var_test_msg,"Hello World")

Label1 Text: var_test_msg

 

You can't use Set and UpdateContext with the same variable name, it's one or the other

Thanks @Pstork1  . 

Thanks @C-Papa . 

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