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

Components - Global variable

I have seen conflicting info regarding components and global variables; is it possible to set a Global Variable on an icon stored in a component?

I have tried the formula below and it does not generate the variable.  (This formula is on the OnSelect of the Home icon.

 

image.png

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: Components - Global variable

@KickingAppsfirst off...I am so excited to see that it appears you are using the concept I outlined in this posting.  

Had this same situation come up in our Component design when using that concept and creating a menu.

The thing is - Global variables, ScreenNames, and pretty much ANYTHING specific to your App is a no-no for a component.  This (IMHO) is by design.  Components are meant to be portable.  You should be able to create a component in one place and use it in many.  If it relies on global variables or other aspects of your App - it will not be portable.

 

So, with that said. You DEFINITELY want to go and vote for this idea.  What we REALLY need in components is an Action that we can "raise".  

In your case (and was mine too) we need to Raise an action that we can put formulas against in our app where our components are used.  So, in our case - being able to define an "OnMenuSelect" action would solve the issue.  Then in the App where we have the component, in the OnMenuSelect action we would put our formulas that are app specific.

 

As it was - my only solution was to expose a numeric property in my menu component that would have the current index of the menu icon selected.  Then in the app I put the component in, I had to set up a toggle as a trigger for when that property changed...and if it did, then I could execute my formula to navigate.

It's spotty and a bit hacked.  And, if I use this menu Component, then I also have to make sure I add a toggle to each screen that is wires to the proper variable. And BTW...you'll definitely want to use a Context variable, not a global for your "checking" - I made the choice at first of a global and when I first clicked on a menu option, the toggle fired, it navigated and then the landing page fired and navigated and so on...it got into an endless loop.

 

What would be nice (in addition to the definable Actions) is a middle ground between App and Component.

The Components are GREAT for portable reuse.  But, sometimes you just need reuse within your App only (and thus could consume global and app variables).  Having that ability would be VERY helpful!

 

Hope this help shed some light.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

1 REPLY 1
Highlighted
Super User
Super User

Re: Components - Global variable

@KickingAppsfirst off...I am so excited to see that it appears you are using the concept I outlined in this posting.  

Had this same situation come up in our Component design when using that concept and creating a menu.

The thing is - Global variables, ScreenNames, and pretty much ANYTHING specific to your App is a no-no for a component.  This (IMHO) is by design.  Components are meant to be portable.  You should be able to create a component in one place and use it in many.  If it relies on global variables or other aspects of your App - it will not be portable.

 

So, with that said. You DEFINITELY want to go and vote for this idea.  What we REALLY need in components is an Action that we can "raise".  

In your case (and was mine too) we need to Raise an action that we can put formulas against in our app where our components are used.  So, in our case - being able to define an "OnMenuSelect" action would solve the issue.  Then in the App where we have the component, in the OnMenuSelect action we would put our formulas that are app specific.

 

As it was - my only solution was to expose a numeric property in my menu component that would have the current index of the menu icon selected.  Then in the app I put the component in, I had to set up a toggle as a trigger for when that property changed...and if it did, then I could execute my formula to navigate.

It's spotty and a bit hacked.  And, if I use this menu Component, then I also have to make sure I add a toggle to each screen that is wires to the proper variable. And BTW...you'll definitely want to use a Context variable, not a global for your "checking" - I made the choice at first of a global and when I first clicked on a menu option, the toggle fired, it navigated and then the landing page fired and navigated and so on...it got into an endless loop.

 

What would be nice (in addition to the definable Actions) is a middle ground between App and Component.

The Components are GREAT for portable reuse.  But, sometimes you just need reuse within your App only (and thus could consume global and app variables).  Having that ability would be VERY helpful!

 

Hope this help shed some light.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

Helpful resources

Announcements
thirdimage

Power Apps Community User Group Member Badge

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

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Kudoed Authors (Last 30 Days)
Users online (3,493)