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 / Taking too Much time t...
Power Apps
Unanswered

Taking too Much time to Generate Hamburger Menu as a Dynamics

(0) ShareShare
ReportReport
Posted on by 12

I am creating a dynamic Hamburger Menu with the check and Uncheck icons based on some specific values, it's taking too long to generate a dynamic one, Logic is something like the below and I am generating approximately 20 menu options Under hamburger, so its taking too much time, Any suggestion, How Can I reduce the time? #PowerApps Community

Sandy6_0-1701867079000.png

 

Categories:
  • Chris-D Profile Picture
    1,246 on at

    I'm assuming that WOMenu is your list of menu items for your hamburger, seems like it's already populated and then you're removing items from it? Seems a bit backwards, wouldn't you add the correct menu items depending on your work order type, rather than add them all then remove them? 

     

    When are you running this code? How is WOMenu being populated? 

  • Sandy6 Profile Picture
    12 on at

    Hi @Chris-D, I am populating WO Menu onVisible of screen, you are correct some values are fixed, and some values I am removing and adding based on the WO type(dropdown), So it's taking too long to load, I am selecting WO from the previous screen from the gallery, and then move to next screen(View Form), and generating WO menu, its taking around 2 min to generate Menu on mobile Internet connection, do you have any idea on that?

  • Chris-D Profile Picture
    1,246 on at

    @Sandy6 I'm not sure why it would take 2 mins, I agree that's a long time! Is WOMenu created with a LookUp to some data source or is it hardcoded? 

     

    If WOMenu and SelectedWO are internal collections/variables, there's no way this should take 2 minutes. 

    Is there any code that preceeds the WOMenu code you showed above which could be causing this delay? What else is on that page? 

  • Sandy6 Profile Picture
    12 on at

    Yes, its hardcoded for now, Its internal Variables and collections.

  • Chris-D Profile Picture
    1,246 on at

    There is a better way to do this, but if that code is all internal then that isn't what's causing your delay. 

     

    Presumably, you're generating WOMenu every time and then modifying it, then passing it as a table to your component. 

     

    You can avoid this by just generating the table directly in your component property like this:

     

    Filter(
     Table(
     If( type = "This", { Title = "Menu Item 1"}),
     If( type = "That", { Title = "Menu Item 2"}),
     If( type = "Something", { Title = "Menu Item 3"})
     ), 
     !IsBlank( ThisRecord)
    )
  • Sandy6 Profile Picture
    12 on at

    Below is my sample Code, do you have any idea, How I can manage it on the backend in the table and use it here, Internal manage means?

     

    ClearCollect(
     WOMenunew,
     Table(
     {
     Title: "Work Order Info",
     MenuIcon: Icon.CheckBadge,
     Screen: WODetailsPage
     },
     {
     Title: "Daily Huddle",
     MenuIcon: 
     Icon.CheckBadge,
     Screen: DailyHuddleScreen
     },
     {
     Title: "Leak Investigation",
     MenuIcon: Icon.CheckBadge, 
     Screen: 'Leak Investigation'
     },
     {
     Title: "Service Call",
     MenuIcon: 
     
     Icon.CheckBadge,
     
     Screen: 'Leak Investigation'
     },
     {
     Title: "Completion Report ",
     MenuIcon: 
     Icon.CheckBadge,
     
     //Fix Icon
     Screen: 'Roof Maintenance'
     },
     {
     Title: "Additional Roof Maintenance",
     MenuIcon:
     Icon.CheckBadge,
     
     //Fix Icon
     Screen: 'Additional Roof Maintenance'
     },
     {
     Title: "Daily Progress Report",
     MenuIcon:
     Icon.CheckBadge,
     
     Screen: 'Daily Progress Report'
     },
     {
     Title: "Completion Report",
     MenuIcon: 
     Icon.CheckBadge,
     
     Screen: 'Completion Report'
     },
     {
     Title: "Additional Photos",
     MenuIcon: Icon.CheckBadge,
     Screen: 'Additional Photos'
     },
     {
     Title: "Add Safety Forms Screen",
     MenuIcon: Icon.CheckBadge,
     Screen: 'Add Safety Forms Screen'
     }
     
    )); ClearCollect(WOMenu, WOMenunew);
     
    
    
    If(SelectedWO.'Work Order Type'.Name = "Leak Investigation" || (SelectedWO.'Work Order Type'.Name = "Service Call"),
    RemoveIf(WOMenu,Title ="Daily Progress Report" || Title = "Completion Report" || Title = "Completion Report "),
    RemoveIf(WOMenu,Title = "Leak Investigation" ||Title = "Service Call")
    
     );
    
     If(
     SelectedWO.'Work Order Type'.Name <> "Leak Investigation" && SelectedWO.'Work Order Type'.Name <> "Service Call" && SelectedWO.'Work Order Type'.Name <> "Roof Maintenance",
     RemoveIf(
     WOMenu,
     Title = "Additional Roof Maintenance"
     )
     
     );
     If(
     SelectedWO.'Work Order Type'.Name = "Leak Investigation",
     RemoveIf(
     WOMenu,
     Title = "Service Call"
     )
     ;
     Set(
     leakRequired,
     true
     );
     );
     If(
     SelectedWO.'Work Order Type'.Name = "Service Call",
     RemoveIf(
     WOMenu,
     
     Title = "Leak Investigation"
     
     );
     Set(
     ServiceCallrequired,
     true
     );
     );
     If(
     SelectedWO.'End Time' <= Now(),
     RemoveIf(
     WOMenu,
     
     Title = "Daily Progress Report"
     
     );
     Set(
     CompletionRequired,
     true
     )
     ,
     RemoveIf(
     WOMenu,
     
     Title = "Completion Report"
     
     )
     );
     If(
     SelectedWO.'Work Order Type'.Name = "Roof Maintenance",
     RemoveIf(
     WOMenu,
     
     Title = "Service Call" || Title = "Leak Investigation" || Title = "Daily Progress Report" || Title = "Completion Report"
     
     );
     
     Set(
     roofmaintenancerequired,
     true
     );
     ,
     RemoveIf(
     WOMenu,
     
     Title = "Completion Report "
     )
     
     );
    
    UpdateIf(WOMenu, Title = "Daily Huddle" ,{MenuIcon: If(
     SelectedWO.'Daily Huddle Report Completed' ,
     Icon.CheckBadge,
     Icon.CancelBadge
     )},Title = "Leak Investigation",{MenuIcon:If(
     SelectedWO.'Leak Report Submitted?',
     Icon.CheckBadge,
     Icon.CancelBadge
     ) }, Title = "Service Call",{MenuIcon:If(
     SelectedWO.'Leak Report Submitted?',
     Icon.CheckBadge,
     Icon.CancelBadge
     ) },Title = "Completion Report",{MenuIcon:If(
     SelectedWO.'Additional Roof Maintenance Review Completed?',
     Icon.CheckBadge,
     Icon.CancelBadge
     ) },Title = "Additional Roof Maintenance",{MenuIcon:If(
     SelectedWO.'Additional Roof Maintenance Review Completed?',
     Icon.CheckBadge,
     Icon.CancelBadge
     ) },Title = "Daily Progress Report",{MenuIcon:If(
     SelectedWO.'Daily Progress Report Completed?',
     Icon.CheckBadge,
     Icon.CancelBadge
     ) },Title = "Completion Report",{MenuIcon:If(
     SelectedWO.'Completion Report Completed?',
     Icon.CheckBadge,
     Icon.CancelBadge
     ) });
    
     If(
     SelectedWO.'Maintenance Safe Work Permit POST',
     Collect(
     WOMenu,
     {
     Title: "Maintenance Safe Work Permit",
     MenuIcon: If(
     SelectedWO.'Maintenance Safe Work Permit Completed',
     Icon.CheckBadge,
     Icon.CancelBadge
     ),
     Screen: 'Maintenance Safe Work Permit Screen'
     }
     ),
     RemoveIf(
     WOMenu,
     Title = "Maintenance Safe Work Permit"
     )
     );
     If(
     SelectedWO.'Working at Heights POST' ,
     Collect(
     WOMenu,
     {
     Title: "Working at heights",
     MenuIcon: If(
     SelectedWO.'Working at Heights Completed?',
     Icon.CheckBadge,
     Icon.CancelBadge
     ),
     Screen: 'Working at heights Sc'
     }
     ),
     RemoveIf(
     WOMenu,
     Title = "Working at heights"
     )
     );
     If(
     SelectedWO.'Near Miss/Hazard Identification POST',
     Collect(
     WOMenu,
     {
     Title: "Near Miss/Hazard Identification",
     MenuIcon: If(
     SelectedWO.'Near Miss/Hazard Identification Completed?',
     Icon.CheckBadge,
     Icon.CancelBadge
     ),
     Screen: 'Near Miss/Hazard Identification'
     }
     ),
     RemoveIf(
     WOMenu,
     Title = "Near Miss/Hazard Identification"
     )
     );
    
    
    
    Collect(
     _WOMenu,
     {
     Title: "Check Out",
     MenuIcon: If(
     SelectedWO.'Please confirm you have completed all required sec',
     Icon.CheckBadge,
     Icon.CancelBadge
     ),
     Screen: 'Check Out'
     }
    );
    Collect(
     WOMenu,
     {
     Title: "Check Out",
     MenuIcon: If(
     SelectedWO.'Please confirm you have completed all required sec',
     Icon.CheckBadge,
     Icon.CancelBadge
     ),
     Screen: 'Check Out'
     }
    );

     

    I have lots of conditions same like this, could you please help me out on urgent basis on that?

  • Chris-D Profile Picture
    1,246 on at

    Can you please edit your post and use a code block to paste that code. I can't read it in that format. 

  • Sandy6 Profile Picture
    12 on at

    Could you please check now and suggest me?

  • Chris-D Profile Picture
    1,246 on at

    @Sandy6 yes that's much better thank you.

     

    I'll be honest, this is waaaaaayyyyy more code than you should need for this. 

     

    Questions:

    WOMenunew, this is your 'master' list?
    WOMenu, this is your modified list for the selected work order?
    _WOMenu?

    Let's get started! I do love an interesting thread. 

     

    First tip, try and keep your code tidy. Readable code is much clearer to understand, debug, and generally look at. 

     

    Next tip, assuming that WOMenunew is your master list, you should define this only once. Here you are defining it every time the page is displayed. Put it in your App.OnStart if it's something you're going to create only once and never change. 

     

    EDIT: In setting up an example page to work on this, I noticed your WOMenunew is defined with ClearCollect() and then a Table(). What this is giving you is a list with one item. That item is a list of items. You're creating a list within a list, then ClearCollect() is merging it back into one list. You can just pass each record individually to ClearCollect(). Also noticed you have "Completion Report" in there twice so I removed on instance. 

    EDITEDIT: I realise now that you have 2 different completion reports. You'll need to name them differently. Don't put a trailing whitespace because that leads to confusion.

     

    I've changed the screen names to text to make it work in my test page because I don't have those screens.

    ClearCollect(
     WOMenunew,
     { Title: "Work Order Info", MenuIcon: Icon.CheckBadge, Screen: "WODetailsPage" },
     { Title: "Daily Huddle", MenuIcon: Icon.CancelBadge, Screen: "DailyHuddleScreen" },
     { Title: "Leak Investigation", MenuIcon: Icon.CancelBadge, Screen: "Leak Investigation" },
     { Title: "Service Call", MenuIcon: Icon.CancelBadge, Screen: "Leak Investigation" },
     { Title: "Completion Report", MenuIcon: Icon.CancelBadge, Screen: "Roof Maintenance" },
     { Title: "Additional Roof Maintenance", MenuIcon: Icon.CancelBadge, Screen: "Additional Roof Maintenance" },
     { Title: "Daily Progress Report", MenuIcon: Icon.CancelBadge, Screen: "Daily Progress Report" },
     { Title: "Additional Photos", MenuIcon: Icon.CheckBadge, Screen: "Additional Photos" },
     { Title: "Add Safety Forms Screen", MenuIcon: Icon.CheckBadge, Screen: "Add Safety Forms Screen" }
    );

     

    I've changed the default icon for "Daily Huddle" and others to CancelBadge because later on you set this based on other parameters to CheckBadge. By setting it to CancelBadge as default, we just need to change it to check if necessary. 

     

    Next thing, try to minimise repetitive code. If you have repetitive code on the inside of a code block, moving it to the outside of the code block means you only have to do that thing once. 

     

    To set the icon badges, your code could look like this:

    ForAll(
     // First, make a list of each menu item and their status
     [
     { MenuTitle: "Daily Huddle", Complete: SelectedWO.'Daily Huddle Report Completed'},
     { MenuTitle: "Leak Investigation", Complete: SelectedWO.'Daily Huddle Report Completed'},
     { MenuTitle: "Service Call", Complete: SelectedWO.'Daily Huddle Report Completed'},
     { MenuTitle: "Completion Report", Complete: SelectedWO.'Daily Huddle Report Completed'},
     { MenuTitle: "Additional Roof Maintenance", Complete: SelectedWO.'Daily Huddle Report Completed'},
     { MenuTitle: "Daily Progress Report", Complete: SelectedWO.'Daily Huddle Report Completed'}
     ],
    
     // Then, if complete, update that item 
     If( Complete, Patch( WOMenu, LookUp( WOMenu, Title = MenuTitle), { MenuIcon: Icon.CheckBadge}))
    );

     

    Have a go with those changes and please repost the whole code so I can make the next steps. 

     

  • Sandy6 Profile Picture
    12 on at

    Hi @Chris-D Below is my sample Code: But its not working, Patch Condition not working for remove and add record.

     

    // Onstart Code
    ClearCollect(
     WOMenu,
     Table(
     {
     Title: "Work Order Info",
     MenuIcon: Icon.CancelBadge,
     Screen: WODetailsPage
     },
     {
     Title: "Daily Huddle",
     MenuIcon: Icon.CancelBadge,
     Screen: DailyHuddleScreen
     },
     {
     Title: "Leak Investigation",
     MenuIcon: Icon.CancelBadge,
     Screen: 'Leak Investigation'
     },
     {
     Title: "Service Call",
     MenuIcon: Icon.CancelBadge,
     Screen: 'Leak Investigation'
     },
     {
     Title: "Completion Report ",
     MenuIcon: Icon.CancelBadge,
     //Fix Icon
     Screen: 'Roof Maintenance'
     },
     {
     Title: "Additional Roof Maintenance",
     MenuIcon: Icon.CancelBadge,
     //Fix Icon
     Screen: 'Additional Roof Maintenance'
     },
     {
     Title: "Daily Progress Report",
     MenuIcon: Icon.CancelBadge,
     Screen: 'Daily Progress Report'
     },
     {
     Title: "Completion Report",
     MenuIcon: Icon.CancelBadge,
     Screen: 'Completion Report'
     },
     {
     Title: "Additional Photos",
     MenuIcon: Icon.CancelBadge,
     Screen: 'Additional Photos'
     },
     {
     Title: "Add Safety Forms Screen",
     MenuIcon: Icon.CancelBadge,
     Screen: 'Add Safety Forms Screen'
     },
     {
     Title: "Daily Safe Work Permit",
     MenuIcon: Icon.CancelBadge,
     Screen: 'Daily Safe Work Permit'
     },
     {
     Title: "Maintenance Safe Work Permit",
     MenuIcon: Icon.CancelBadge,
     Screen: 'Maintenance Safe Work Permit Screen'
     },
     {
     Title: "Working at heights",
     MenuIcon: Icon.CancelBadge,
     Screen: 'Working at heights Sc'
     },
     {
     Title: "Near Miss/Hazard Identification",
     MenuIcon: Icon.CancelBadge,
     Screen: 'Near Miss/Hazard Identification'
     },
     {
     Title: "Heavy Equipment Lifting",
     MenuIcon: Icon.CancelBadge,
     Screen: 'Heavy Equipment Lifting Screen'
     },
     {
     Title: "Accident Investigation Report",
     MenuIcon: Icon.CancelBadge,
     Screen: 'Accident Investigation Report'
     },
     {
     Title: "Incident Report Form",
     MenuIcon: Icon.CancelBadge,
     Screen: 'Incident Report Form'
     },
     {
     Title: "Hot Work Permit",
     MenuIcon: Icon.CancelBadge,
     Screen: 'Hot Work Permit'
     },
     {
     Title: "Daily Hoist Inspection",
     MenuIcon: Icon.CancelBadge,
     Screen: 'Daily Hoist Inspection Screen'
     },
     {
     Title: "Daily Aerial-Elevated",
     MenuIcon: Icon.CancelBadge,
     Screen: 'Daily Aerial-Elevated'
     },
     {
     Title: "Fall Protection/ Rescue Equipment",
     MenuIcon: Icon.CancelBadge,
     Screen: 'Fall Protection / Rescue Equipment'
     },
     {
     Title: "Daily Telehandler Inspection",
     MenuIcon: Icon.CancelBadge,
     Screen: 'Daily Telehandler Inspection Screen'
     },
     {
     Title: "Fall Protection PPE",
     MenuIcon: Icon.CancelBadge,
     Screen: 'Fall Protection PPE Screen'
     },
     {
     Title: "Daily Skidsteer Operator Inspection",
     MenuIcon: Icon.CancelBadge,
     Screen: 'Daily Skid steer Operator Inspection Screen'
     },
     {
     Title: "Daily Kettle Tanker Inspection",
     MenuIcon: Icon.CancelBadge,
     Screen: 'Daily Kettle Tanker Inspection sc'
     },
     {
     Title: "Check Out",
     MenuIcon: Icon.CancelBadge,
     Screen: 'Check Out'
     }
     )
    );
    
    // On Visible WO Screen
    ForAll(
     [
     {
     MenuTitle: "Daily Huddle",
     Completed: SelectedWO.'Daily Huddle Report Completed'
     },
     {
     MenuTitle: "Leak Investigation",
     Completed: SelectedWO.'Leak Report Submitted?'
     },
     {
     MenuTitle: "Service Call",
     Completed: SelectedWO.'Leak Report Submitted?'
     },
     {
     MenuTitle: "Completion Report",
     Completed: SelectedWO.'Additional Roof Maintenance Review Completed?'
     },
     {
     MenuTitle: "Additional Roof Maintenance",
     Completed: SelectedWO.'Additional Roof Maintenance Review Completed?'
     },
     {
     MenuTitle: "Daily Progress Report",
     Completed: SelectedWO.'Daily Progress Report Completed?'
     },
     {
     MenuTitle: "Completion Report",
     Completed: SelectedWO.'Completion Report Completed?'
     },
     {
     MenuTitle: "Daily Safe Work Permit",
     Completed: SelectedWO.'Daily Safe Work Permit Completed'
     },
     {
     MenuTitle: "Maintenance Safe Work Permit",
     Completed: SelectedWO.'Maintenance Safe Work Permit Completed'
     },
     {
     MenuTitle: "Working at heights",
     Completed: SelectedWO.'Working at Heights Completed?'
     },
     {
     MenuTitle: "Near Miss/Hazard Identification",
     Completed: SelectedWO.'Near Miss/Hazard Identification Completed?'
     },
     {
     MenuTitle: "Heavy Equipment Lifting",
     Completed: SelectedWO.'Heavy Equipment Lifting Completed?'
     },
     {
     MenuTitle: "Accident Investigation Report",
     Completed: SelectedWO.'Accident Investigation Form Completed?'
     },
     {
     MenuTitle: "Incident Report Form",
     Completed: SelectedWO.'Incident Report Form Completed'
     },
     {
     MenuTitle: "Hot Work Permit",
     Completed: SelectedWO.'Hot Work Permit Completed?'
     },
     {
     MenuTitle: "Daily Hoist Inspection",
     Completed: SelectedWO.'Daily Hoist Inspection Completed?'
     },
     {
     MenuTitle: "Daily Aerial-Elevated",
     Completed: SelectedWO.'Daily Aerial/Elevated Work Platform Completed?'
     },
     {
     MenuTitle: "Fall Protection/ Rescue Equipment",
     Completed: SelectedWO.'Fall Protection / Rescue Equipment Checklist Com?'
     },
     {
     MenuTitle: "Daily Telehandler Inspection",
     Completed: SelectedWO.'Daily Telehandler Inspection Completed?'
     },
     {
     MenuTitle: "Fall Protection PPE",
     Completed: SelectedWO.'Fall Protection PPE Inspection Completed?'
     },
     {
     MenuTitle: "Daily Skidsteer Operator Inspection",
     Completed: SelectedWO.'Daily Skidsteer Inspection Completed?'
     },
     {
     MenuTitle: "Daily Kettle Tanker Inspection",
     Completed: SelectedWO.'Daily Kettle Tanker Inspection Completed?'
     },
     {
     MenuTitle: "Check Out",
     Completed: SelectedWO.'Please confirm you have completed all required sec'
     },
     ],
    
     If(
     Completed = "Yes",
     Patch(
     WOMenu,
     LookUp(
     WOMenu,
     Title = MenuTitle
     ),
     {MenuIcon: Icon.CheckBadge}
     ),
     RemoveIf(
     WOMenu,
     Title = MenuTitle
     )
     )
    );
    If(
     SelectedWO.'Work Order Type'.Name = "Leak Investigation",
     RemoveIf(
     WOMenu,
     Title = "Service Call"
     );
     Set(
     leakRequired,
     true
     );
     
    );
    If(
     SelectedWO.'Work Order Type'.Name = "Service Call",
     RemoveIf(
     WOMenu,
     Title = "Leak Investigation"
     );
     Set(
     ServiceCallrequired,
     true
     );
     
    );
    If(
     SelectedWO.'End Time' <= Now(),
     RemoveIf(
     WOMenu,
     Title = "Daily Progress Report"
     );
     Set(
     CompletionRequired,
     true
     ),
     RemoveIf(
     WOMenu,
     Title = "Completion Report"
     )
    );
    If(
     SelectedWO.'Work Order Type'.Name = "Roof Maintenance",
     RemoveIf(
     WOMenu,
     Title = "Service Call" || Title = "Leak Investigation" || Title = "Daily Progress Report" || Title = "Completion Report"
     );
     Set(
     roofmaintenancerequired,
     true
     );
     ,
     RemoveIf(
     WOMenu,
     Title = "Completion Report "
     )
    );

     

     

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 411 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 338

#3
WarrenBelz Profile Picture

WarrenBelz 256 Most Valuable Professional

Last 30 days Overall leaderboard