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 / Debugging app in play ...
Power Apps
Answered

Debugging app in play mode

(0) ShareShare
ReportReport
Posted on by 1,246

Hi all, I'm struggling to debug a bug. 

 

In the editor (and in play mode in the editor) everything works fine. 

 

In play mode, on web or mobile, the first time I navigate to one of the problem pages (I suspect one bug is causing the same problem on each), I get a divide by zero error. 

 

I've enabled 'Debug Published App' but I'm not seeing any activity in the monitor.

 

How can I debug this? 

Categories:
  • Krzysztof Borkowski Profile Picture
    Microsoft Employee on at

    Handle the Error with IfError(), you will see the Error in Monitor, but you won't get that message on your Mobile app or while playing the app. Error, IfError, IsError, and IsBlankOrError functions - Power Platform | Microsoft Learn

  • Chris-D Profile Picture
    1,246 on at

    Thanks for your reply. 

     

    Those functions seem to rely on knowing where the error is. 

     

    In addition to my original post I've been doing some testing. I duplicated the page and deleted things from it one by one until the error disappeared. The error disappeared when I deleted a (now empty) container where none of the properties used the divide function. In fact, by this point there wasn't a divide function on the page at all. 

     

    I rebuilt the container, and the problem came back when I inserted a gallery that relied on the following in the page OnVisible:

    // Set up gallery
    UpdateContext({ GalleryInternalHeight: CO_GalleryBarcodes.Height -CO_GalleryBarcodes.BorderThickness}); 
    UpdateContext({ GalleryNumItems: Int( GalleryInternalHeight / UI.Controls.Height)});
    UpdateContext({ GalleryTemplateHeight: GalleryInternalHeight / GalleryNumItems});

     

    Deleting the gallery did not then resolve the problem, the entire container has to be deleted. It's like somehow the error is polluting the container, seems like this is a bug. 

     

    Aside from that, I'm not sure why the above code would cause this? 

  • Krzysztof Borkowski Profile Picture
    Microsoft Employee on at

    UI.Controls.Height cannot be 0, GalleryNumItems cannot be 0, but OnLoad/OnStart those might be set to 0. I run into similar issue recently when was calculating a progress bar length. So I put IfError for each of formulas that can div=0. ¯\_(ツ)_/¯

    (Parent.Width-8)/IfError((Coalesce(CountRows(Index(colQuizzes,IfError(varRecord.RowNumber,1)).questions),1)/varQuestionCounter),1)

     

  • Chris-D Profile Picture
    1,246 on at

    This is the same code on a different page with the same issue (the gallery name is the only difference):

     

    UpdateContext({ GalleryInternalHeight: C_GalleryBarcodes_1.Height -C_GalleryBarcodes_1.BorderThickness}); 
    
    If( GalleryInternalHeight = 0, Notify("ZERO GalleryInternalHeight"));
    If( UI.Controls.Height = 0, Notify("ZERO UI.Controls.Height"));
    
    UpdateContext({ GalleryNumItems: Int( GalleryInternalHeight / UI.Controls.Height)});
    
    If( GalleryNumItems = 0, Notify("ZERO GalleryNumItems"));
    
    UpdateContext({ GalleryTemplateHeight: GalleryInternalHeight / GalleryNumItems});

     

    I DO NOT get the warning notifications. 

    I DO get divide by zero error. 

    I DO NOT use the divide function anywhere else on the page. 

     

    The UI object is set on AppStart btw and used in hundreds of places, it's definitely not 0 at this point. 

     

  • Krzysztof Borkowski Profile Picture
    Microsoft Employee on at

    As I said, Had exactly the same struggle, error happens twice before the screen is loaded. However I have only one container where that width is calculated. Once I wrapped my expression in IfError() my app loads without any error message for the end user. 
    Try the updated code below and see if you got this error message after publishing your app:

    UpdateContext({ GalleryInternalHeight: C_GalleryBarcodes_1.Height -C_GalleryBarcodes_1.BorderThickness}); 
    
    If( GalleryInternalHeight = 0, Notify("ZERO GalleryInternalHeight"));
    If( UI.Controls.Height = 0, Notify("ZERO UI.Controls.Height"));
    
    UpdateContext({ GalleryNumItems: Int( GalleryInternalHeight / IfError(UI.Controls.Height,1))});
    
    If( GalleryNumItems = 0, Notify("ZERO GalleryNumItems"));
    
    UpdateContext({ GalleryTemplateHeight: GalleryInternalHeight / IfError(GalleryNumItems,1)});



    Screenshot 2023-11-13 152623.pngScreenshot 2023-11-13 152531.png

  • Chris-D Profile Picture
    1,246 on at

    This is off topic. 

    My original question was about how to debug a published app, I'm more than capable of fixing errors myself if I know where they are. 

     

    Your debug session says 'Published app session' at the top, I don't know how to get that? I can only get 'Studio session' and I can't see how I can change that? 

     

  • Verified answer
    Krzysztof Borkowski Profile Picture
    Microsoft Employee on at

    As you share the app, the user can go to make.powerapps.com and open details > Monitor and check. 

    Screenshot 2023-11-13 164703.pngScreenshot 2023-11-13 164626.png

    You can also share the link from Monitor.

    Screenshot 2023-11-13 165002.png

  • Chris-D Profile Picture
    1,246 on at

    Now, that information was invaluable 🙂 

     

    I never had to debug an app in play mode, didn't realise you could do it this way. 

     

    Turned out I was having quite a few failures in the background, nothing too serious, but the DIV/0 in question was in a component. It relied on the UI.Controls.Height variable, however here's the odd thing: Even though this variable is set before navigating to the page, there is a point BEFORE the page is loaded where this condition is evaluated as 0. 

     

    This was happening after the Navigate() function, but before the LoadScreen (Success) event. 

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 339 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 289

#3
Mohsin Ali Profile Picture

Mohsin Ali 228

Last 30 days Overall leaderboard