cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Update or reset component variables by opening screen

Hi there,

 

I've created an app with multiple screens. Each screen has a menu that can be opened via a component. The menu is created via the solution as mentioned in  Components - Screen Navigation .

 

Clicking on the component opens the menu. Adding the same component to multiple screens means that every component gets a different name.  The menu's visible property for screen 8 is set to:

If(Q08MenuFooter.MenuGlobal = "Menu" , true, false)

The point is that the variable that is being updated for screen 8 applies to all screens. So the menu appears on every screen. As a result, the user must first switch it off again.

Is it possible to update or reset the variable that is created / set in a component when opening a screen?

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Anonymous ,

Do you initialize your variable within your Component control?

Do you want to set the variable value outside the Component control?

 

Based on the needs that you mentioned, I think the OnRest property of the Component control could achieve your needs.

I have made a test on my side, please take a try with the following workaround:5.JPG

 

6.JPG

Please set the OnReset property of your Component control (Component1) to following:

Set(yourGlobalVar, "Edit")

Then within your screen, set the OnVisbile property to following:

Reset(Component1)

Please consider take a try with above solution, then check if the issue is solved.

 

Also please check if the following article would help in your scenario:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/component-behavior

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
RezaDorrani
Dual Super User
Dual Super User

Hi @Anonymous 

 

If you add a property to the component itself that sets the menu to be hidden, then each component element added to each screen can set the property specific to the screen 

 

Regards,

Reza Dorrani

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Anonymous
Not applicable

Hi @RezaDorrani ,

 

thank you for your answer.

I'm not sure if I understand it correctly.

 

In the app people can open a menu screen (gallery) with all 16 items (screens). These items navigates the person to the selected screen. So far so good.

For example, when the person has screen Q07 open and navigates via the menu to screen Q04 all is fine. When he navigates back to screen Q07, the menu is still open and it's not very clear for the person that he reached Q07.
Via a few icons in a component and an output property he can activate and deactivate this menu. Selecting the menu icon sets a global variable via the output property to "Menu". Select another icon sets the same variable to "Edit." 

 

So what I want is that when the screen gets visible the variable automatically is set to Edit. For example via the onVisible control.

Thing is that a variable set by a component is not editable outside the component.

 

Can you give me some more advice?

Thanks in advance.

 

Hi @Anonymous ,

Do you initialize your variable within your Component control?

Do you want to set the variable value outside the Component control?

 

Based on the needs that you mentioned, I think the OnRest property of the Component control could achieve your needs.

I have made a test on my side, please take a try with the following workaround:5.JPG

 

6.JPG

Please set the OnReset property of your Component control (Component1) to following:

Set(yourGlobalVar, "Edit")

Then within your screen, set the OnVisbile property to following:

Reset(Component1)

Please consider take a try with above solution, then check if the issue is solved.

 

Also please check if the following article would help in your scenario:

https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/component-behavior

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi @v-xida-msft ,

 

thank you for your response.

The reset function in combination with the onvisible property did the trick.

 

Thanks!

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (3,107)