Showing results for 
Search instead for 
Did you mean: 
Level: Powered On

Dynamically set onselect function

Has anyone ever dynamically applied what will occur within an onselect based on what has been defined within a collection. For example, on the home screen menu of an app I have created, I am using a collection to define what what appears and what does not appear. This collection is also used on other screens for a drop-down navigation. This approach allows me to keep all of the menus updated in one place instead of having to go to every screen.


I am now running to the scenario where I want to have one screen to present different data by passing parameters from home screen or app menu.


Can you pass functions as variables like the following:


{menulabel: "PowerApps RSS", onselect:"Navigate(RSSreader,ScreenTransition.Cover,{feedname: 'PowerApps', feedurl: ''})"}, {menulabel: "Flow RSS", onselect:"Navigate(RSSreader,ScreenTransition.Cover,{feedname: 'Flow', feedurl: ''})"}


Any direction or help is appreciated.

Power Apps Staff CarlosFigueira
Power Apps Staff

Re: Dynamically set onselect function

Creating an expression from a string value is currently not supported - please create a new feature request in the PowerApps Ideas board if you believe it's a scenario we should support.


For your scenario, you can consider specifying the parameters in a generic collection that will be available to the screen where the menu navigates. For example, if you have this in the OnVisible property of your first (menu) screen:

    { menuLabel: "PowerApps RSS", screen: RSSReader, params:
Table({ name:"feedname",value:"PowerApps" }, {name:"feedurl",value:"" })}, { menuLabel: "Flow RSS", screen: RSSReader, params:
Table({ name:"feedname",value:"Flow" }, {name:"feedurl",value:"" })}, { menuLabel: "Other", screen: AnotherScreen, params:
Table({ name:"first",value:"First value" })})

Then you can on the OnSelect property of the menu that navigates to that screen store the screen parameters in a collection:

ClearCollect(screenParameters, ThisItem.params);
Navigate(ThisItem.screen, ScreenTransition.Cover)

Now in the screens you can use a LookUp to retrieve the value that was passed to it. For example, in the RSSreader screen, the following two expressions will give you the value of the feedname and feedurl parameters:

LookUp(screenParameters, name = "feedname", value)
LookUp(screenParameters, name = "feedurl", value)

This is a very generic option that can be used for many scenarios.


Another alternative, if the parameters that are passed to the screens are always the same (which is the case in your example below), then we can use the parameters directly:

MenuScreen.OnVisible: ClearCollect(menuOptions,
    { menuLabel: "PowerApps RSS", screen: RSSReader, feedname:"PowerApps",feedurl:""},
    { menuLabel: "Flow RSS", screen: RSSReader, feedname:"Flow",feedurl:""})

    Set(feedname, ThisItem.feedname);
    Set(feedurl, ThisItem.feedurl);
    Navigate(ThisItem.screen, ScreenTransition.Cover)

And on the screens you can access the variables 'feedname' and 'feedurl' directly.

Level: Powered On

Re: Dynamically set onselect function


Thank you for providing the different options. I ended up going with a hybrid of the options you provided. Given the navigation can be a combination of RSS and other features/functions, I have created a node called variables and I set a global variable with those values. For example,


{menuLabel: "Microsoft Flow RSS", screen: "RSSReader", variables: {rssLabel: "Micorsoft Flow RSS Feed", rssURL:""}


so the onselect function looks like the following:



On the destination screen, I reference the values as such:



Helpful resources


Power Apps Super User Class of 2020

Check it out!


New Badges

Check it out!


Power Apps Community User Group Member Badge

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


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


Difinity Conference

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

Top Solution Authors
Top Kudoed Authors
Users online (4,524)