Skip to main content

Notifications

Power Apps - Building Power Apps
Suggested answer

Best practice navigating to external site from menu

Like (0) ShareShare
ReportReport
Posted on 18 Dec 2024 11:10:02 by 98
Hello,
 
I am using a component as my menu and I have the menu items set to load the CustomNavigation.
I've build my menu in my App's Formula's so I can easily load the same menu on all my different pages.
 
My App Formula's looks like this:
CustomNavigation = Table (
   {
        MenuName: "Item 1",
        MenuID: 7,
        PageNavigation: Screen1
    },
    {
        MenuName: "Item 2",
        MenuID: 8,
        PageNavigation: Screen2
    }
)
 
 
 
For the first menu item "Item 1" it navigates to Screen1, but for Item 2 I want it to navigate to an external website.
Usually you can do this using the Launch() function, but that doesn't seem to work in my case.
 
As a workaround I've made it so that it goes to Screen2. Then on Screen2 I run a timer set to 1 sec to launch to the external site and navigate back to my home screen.
This works, but I'm looking for a better solution since I don't like it.
 
What I want, is to update the App's Formula to something like this:
CustomNavigation = Table (
    {
        MenuName: "Item 2",
        MenuID: 8,
        PageNavigation: Launch("https://www.example.com")
    }
)
 
This doesn't work. I get an error (screenshot attached) saying: "Behavior function in a non-behavior property. You can't use this property to change values elsewhere in the app"
 
How can I easily make this work? All I want is to update my PageNavigation to launch the external website directly from the menu. I don't link to my current workaround to navigate to another screen with a timer to redirect back to my home screen and to launch the external site on timerend.
 
 
 
 
Categories:
  • WesleyE Profile Picture
    WesleyE 98 on 21 Dec 2024 at 14:13:54
    Best practice navigating to external site from menu
    I was able to test the code and I've got everything working, thanks so much! A much better fix!
     
    I do have some error though on my menu items, it's telling me "expected a different collection record structure.", but everything works as expected. It's not a red error, it's the yellow one, like a delegation error. 
     
    Do you have that as well? Maybe something is wrong in my table still, I'll take a look later.
  • WesleyE Profile Picture
    WesleyE 98 on 20 Dec 2024 at 20:38:02
    Best practice navigating to external site from menu
    Thanks for your reply! I haven't had a chance yet to test your solution, but hopefully I will somewhere next week.
     
    By looking at your code I do have some questions though.
     
    As "MenuURLNavigate" you have it configured as "gstrURL_SIAdmin" what is this?
    Would I be able to replace that with the Launch code? like Launch("https://www.example.com")?
     
     
    I assume this is the "button" code in your menu component? right?
    If(ThisItem.MenuScreenNavigate.Name <> Blank(),
        Navigate(ThisItem.MenuScreenNavigate);
    );
    If(ThisItem.MenuURLNavigate <> Blank(),
        Launch(ThisItem.MenuURLNavigate, Blank(), "New")
    );
     
     
    I guess it'll make more sense when I am able to test the code myself :)
  • Suggested answer
    abc 123 Profile Picture
    abc 123 655 on 18 Dec 2024 at 15:03:19
    Best practice navigating to external site from menu
    Just did this last week. First, update the table to contain another parameter:
     
    Set(gtblMenuVert_MenuItems,
        Table(
            If(gcfAdminSI,
                {
                Image: pngHome,
                MenuID: 1,        
                MenuLabel: "Admin",
                MenuURLNavigate: gstrURL_SIAdmin,
                SubMenu: Table({
                        MenuLabel: "Reference Data",
                        Image: pngEnergy,
                        MenuScreenNavigate: Blank(),
                        MenuURLNavigate: gstrURL_SIAdmin,
                        MenuID: 1.1
                    })
     
    Next, modify the component menu item to handle the different actions:
    If(ThisItem.MenuScreenNavigate.Name <> Blank(),
        Navigate(ThisItem.MenuScreenNavigate);
    );
    If(ThisItem.MenuURLNavigate <> Blank(),
        Launch(ThisItem.MenuURLNavigate, Blank(), "New")
    );
     
     

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

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #9 Get Recognized…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,867

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,161

Leaderboard
Loading started