Skip to main content

Notifications

Power Apps - Building Power Apps
Unanswered

Problem - Container wont show on app load as value blank

Posted on by

I have a container that will not show when the app loads onto homescreen, this is because its blank. In order for it to show it needs to be true, however, this means it willl always show, and if i set it to true which will result in there being two containers squashed on the screen. I have tried the below to check if its blank, and the set it to true if blank etc. 

 

UpdateContext({showNM:If(showNM = Blank(), true, If(showNM = true, true, If(showNM = false, false)),false))

 

However, this does not work, i think it is due to using "UpdateContext" within the visible attribute.

 

Thank you

  • M_Ali_SZ365 Profile Picture
    M_Ali_SZ365 1,132 on at
    Re: Problem - Container wont show on app load as value blank

    Hi @PowerNovice ,

    Try This Code

    // Initialize the 'showNM' variable in the OnStart event
    Set(showNM, false);
    
    // Use this in the Visible property of your container
    Visible = showNM
    
    // To toggle visibility of the container, use the following in a button's OnSelect event
    UpdateContext({showNM: !showNM});
    
    // Ensure the navigation menu is not duplicated by checking before collecting items
    If(IsEmpty(colNavMenuItems), 
     Collect(colNavMenuItems, {
     ScreenName: "Home",
     Screen: LandingScreen
     // ... add other menu items here
     })
    );
    
    // Set the user variable without causing duplication
    Set(varUser, User());

    Please accept this solution if it resolves the issue. ✅
    Best regards,
    Muhammad Ali

  • PowerNovice Profile Picture
    PowerNovice on at
    Re: Problem - Container wont show on app load as value blank

    I think the problem for duplication is because i am initializing the nav menu in onstart as well, but it doesnt make sense because im also doing set(varUser,User()) with no problems at all.

     

    PowerNovice_1-1699519277473.png

     

     

  • M_Ali_SZ365 Profile Picture
    M_Ali_SZ365 1,132 on at
    Re: Problem - Container wont show on app load as value blank

    Hi @PowerNovice 

    t seems you're facing issues with duplicating the navigation menu and the container not displaying correctly. To fix this:

    1. Check the code that toggles "showNM" to ensure it's not affecting the navigation menu.
    2. Review the container's visibility condition, which should be set to showNM.
    3. Verify the container's position and other conditions that control its visibility.

    These steps should help you resolve the problems and achieve the desired behavior without unintended side effects.

  • M_Ali_SZ365 Profile Picture
    M_Ali_SZ365 1,132 on at
    Re: Problem - Container wont show on app load as value blank

    Hi @PowerNovice 

    In This Code

    The code UpdateContext({showNM: !showNM}) is used to toggle a variable called "showNM" between true and false. If "showNM" is currently true, it will become false, and if it's currently false, it will become true. Make sure to initialize "showNM" with an initial value,

    Use the same button for true or false 
    Please accept this solution if it resolves the issue. ✅
    Best regards,
    Muhammad Ali

  • PowerNovice Profile Picture
    PowerNovice on at
    Re: Problem - Container wont show on app load as value blank

    @M_Ali_SZ365 i now remember why i deleted that way of doing it, it duplicates the navigation menu in the sidebar. It also doesnt show the container that i need it to. 

  • PowerNovice Profile Picture
    PowerNovice on at
    Re: Problem - Container wont show on app load as value blank

    Hi @M_Ali_SZ365

     

    I tried initialising the variable at the start but it was a throwing an error, the only thing thats different on this example from the first way i tried is before the long way i posted on this, is you've done "!showNM" whereas i set that to true or false. 

     

    I'll give your way a go now. Thank you! 

  • M_Ali_SZ365 Profile Picture
    M_Ali_SZ365 1,132 on at
    Re: Problem - Container wont show on app load as value blank

    Hi @PowerNovice ,

    1. Initialize your variable correctly on app start.
    2. Set the container's Visible property based on this variable.

    First, set up your context variable when the app starts. This is usually done in the OnStart event of the app:

     

    Set(showNM, true);

     

     

    Next, for the container's Visible property, simply reference this variable:

     

    showNM

     

    This means when the app loads, showNM is set to true, so your container will show. When showNM is false, the container will be hidden.

    If you want to toggle this variable within the app, use a button or some other control with the following code:

     

    UpdateContext({showNM: !showNM});

     

     This will switch showNM between true and false each time the button is pressed. Remember, UpdateContext is used for local variables, and Set is used for global variables that are accessible across screens.

    Please accept this solution if it resolves the issue. ✅
    Best regards,
    Muhammad Ali

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 #7 Community Profile Tips…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,532

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,050

Leaderboard