cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
emfuentes27
Super User
Super User

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

emfuentes27
Super User
Super User

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

Mark Your Calendars

So many events that are happening this month - don't miss out!

Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

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

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