cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
emfuentes27
Resolver II
Resolver II

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

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
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (2,968)