web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Dynamically set onsele...
Power Apps
Unanswered

Dynamically set onselect function

(0) ShareShare
ReportReport
Posted on by 31

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: 'https://powerapps.microsoft.com/en-us/blog/feed/'})"}, {menulabel: "Flow RSS", onselect:"Navigate(RSSreader,ScreenTransition.Cover,{feedname: 'Flow', feedurl: 'https://us.flow.microsoft.com/en-us/blog/feed/'})"}

 

Any direction or help is appreciated.

Categories:
  • CarlosFigueira Profile Picture
    Microsoft Employee on at

    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:

    ClearCollect(menuOptions,
     { menuLabel: "PowerApps RSS", screen: RSSReader, params:
    Table({ name:"feedname",value:"PowerApps" }, {name:"feedurl",value:"https://powerapps.microsoft.com/blog/feed/" })}, { menuLabel: "Flow RSS", screen: RSSReader, params:
    Table({ name:"feedname",value:"Flow" }, {name:"feedurl",value:"https://us.flow.microsoft.com/blog/feed/" })}, { 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:"https://powerapps.microsoft.com/blog/feed/"},
     { menuLabel: "Flow RSS", screen: RSSReader, feedname:"Flow",feedurl:"https://us.flow.microsoft.com/blog/feed/"})
    
    MenuArrow.OnSelect:
     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.

  • tzavertnik Profile Picture
    31 on at

    Carlos,

    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:"https://us.flow.microsoft.com/blog/feed/"}

     

    so the onselect function looks like the following:

    Navigate(ThisItem.screen,ScreenTransition.Cover);Set(menuVar,ThisItem.variables)

     

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

    menuVar.rssLabel

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 395 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 260 Most Valuable Professional

Last 30 days Overall leaderboard