cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
emfuentes27
Advocate III
Advocate III

Pass component output to App global variable

I created a navigation menu using galleries, and it works just fine. The gallery items are fed from a table. This is just a sample:

 

Table(
    {
        Agency: "AA",
        ItemType: "AA Tracking",
        Icon: Icon.AddDocument,
        SubMenuTitle: "New Request",
        Screen: App.ActiveScreen,
        SubMenuIcon: Icon.Add,
        formType: "New"
    },
    {
        Agency: "BB",
        ItemType: "BB Tracking",
        Icon: Icon.AddDocument,
        SubMenuTitle: "Email Office",
        Screen: App.ActiveScreen,
        SubMenuIcon: Icon.Mail,
        formType: "Edit"
    },....)

 When I click on one of the galley items (a button), I create a variable:

 

Set(theFormType,ThisItem.formType );Navigate(ThisItem.Screen);

 

The output property FormTypeOut is assigned that value:

Annotation 2021-07-13 164159.jpg

 

I add my component to the App' screen. I can create a label, and make set the text to that component output (multiNav_1.FormTypeOut), and it works just fine also. The thing is that I don't know how to pass that output to a global variable instead of just a text. When I click on the navigation items depending what I chose it'll open a form either in New mode or Edit mode, and I don't know how to set a variable when I click on the component that has been added to the screen. I feel like I'm missing something very simple somewhere.

 

thanks.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-bofeng-msft
Community Support
Community Support

Hi @emfuentes27 :

The key is that the "global variable" created in a component is not a real global variable, it can only take effect as a local variable in the current component.

If you want to save the result of multiNav_1.FormTypeOut to a variable, then I suggest you consider other alternatives.For example:

Because once the button in this custom component is triggered, your App will be navigated to other screens, so you can consider setting the OnVisible property of these screens to:

 

Set(Thevariable,multiNav_1.FormTypeOut)

 

 If you do this, whenever you switch to another screen, the OnVisible event of this screen will be triggered and the value of multiNav_1.FormTypeOut will be saved into the variable "Thevariable".

Best Regards,

Bof

View solution in original post

2 REPLIES 2
v-bofeng-msft
Community Support
Community Support

Hi @emfuentes27 :

The key is that the "global variable" created in a component is not a real global variable, it can only take effect as a local variable in the current component.

If you want to save the result of multiNav_1.FormTypeOut to a variable, then I suggest you consider other alternatives.For example:

Because once the button in this custom component is triggered, your App will be navigated to other screens, so you can consider setting the OnVisible property of these screens to:

 

Set(Thevariable,multiNav_1.FormTypeOut)

 

 If you do this, whenever you switch to another screen, the OnVisible event of this screen will be triggered and the value of multiNav_1.FormTypeOut will be saved into the variable "Thevariable".

Best Regards,

Bof

View solution in original post

emfuentes27
Advocate III
Advocate III

Thanks. I thought about the onVisible option yesterday, but I was hopping something more "elegant". I guess that's the Microsoft way.

Helpful resources

Announcements
User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Power Apps Community Call Jan. 2022 768x460.png

Power Apps Community Call

Please join us on Wednesday, January 19th, at 8a PDT. Come and learn from our amazing speakers!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (2,413)