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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Time Out due to Canvas...
Power Apps
Unanswered

Time Out due to Canvas app Inactivity

(1) ShareShare
ReportReport
Posted on by 2
In Canvas app user should be able to navigate to multiple Canvas applications in multiple tabs based on selection from core application. When user inactive for 30 minutes, user should get time out notification due to inactivity with two options 'Extend the session' or 'Log off' from the application. If no response should log out.
 
Is there a possibility to implement Canvas application with custom page time out component for above requirements. If yes, please help me with the solution.
Categories:
I have the same question (0)
  • Suggested answer
    BCBuizer Profile Picture
    22,505 Super User 2025 Season 2 on at
     
    Thanks for your interesting question. Based on it, I experimented a bit and created a basic component that should do what you describe. The YAML for the component can be found at the bottom of this reply. 
     
    Introduction
     
    Basically the component will show a modal, asking the user if they wish to continue, or not, after a certain time. If there is no timely response, the app will be exited automatically. Certain properties are available to set the behaviour of the component:
     
    Input:
    • MaxInactivityDuration:
      • This is the amount of miliseconds at which the app will be exited automatically.
      • By default this is set to 30000 miliseconds (30 minutes)
    • ShowModalDuration: 
      • This is the amount of miliseconds at which the modal becomes visible to ask to continue or not.
      • By default this is set to 25000 miliseconds (25 minutes)
    • ModalHeight:
      • This is the heigth of the modal in px.
      • By default this is set to 200
    • ModalText:
      • This is the text of the modal as text.
      • By default this is set to "This session will be ended automatically in X minute(s) and Y second(s). Do you wish to continue?"
    • ModalWidth: 
      • This is the width of the modal in px.
      • By default this is set to 500
    • Reset:
      • This property allows to reset the timer.
      • By default this is set to be triggered whenever the screen in which the component is placed becomes active. This effectively resets the timer every time the user changes screens.
    Output: 
    • InactivityTimerValue:
      • This gives the current value of the timer in milliseconds
     
    Using the component*:
    1. In your app, in the tree view, select Components and then add a new component.
    2. Copy the below YAML code
    3. Right click the component you added and select Paste Code
    4. Remove the component you created in step 1 (this was only needed to be able to perform step 3).
    5. In the tree view select Screens
    6. Add the component (named cmpAutoExit) to any screen where you need it, but make sure it is in the front of the screen.
     
    * In case you want to use the component across multiple apps, I suggest you use a component library instead of steps 1-5: https://learn.microsoft.com/en-us/power-apps/maker/canvas-apps/component-library
     
    YAML code snippet:
    ComponentDefinitions:
      cmpAutoExit:
        DefinitionType: CanvasComponent
        CustomProperties:
          InactivityTimerValue:
            PropertyKind: Output
            DisplayName: InactivityTimerValue
            Description: Custom Property
            DataType: Number
          MaxInactivityDuration:
            PropertyKind: Input
            DisplayName: MaxInactivityDuration
            Description: Custom Property
            DataType: Number
            Default: =300000
          ModalHeight:
            PropertyKind: Input
            DisplayName: ModalHeight
            Description: Custom Property
            DataType: Number
            Default: =200
          ModalText:
            PropertyKind: Input
            DisplayName: ModalText
            Description: Custom Property
            DataType: Text
            Default: |-
              =$"This session will be ended automatically in {
                  With(
                      {SecondsLeft: 
                      RoundDown((Self.MaxInactivityDuration - Self.InactivityTimerValue) / 1000, 0)
                      },
                      $"{RoundDown(SecondsLeft/60,0)} minute(s) and {Mod(SecondsLeft,60)} second(s)"
                  )
                  } due to inactivity.
    
              Do you wish to continue?"
          ModalWidth:
            PropertyKind: Input
            DisplayName: ModalWidth
            Description: Custom Property
            DataType: Number
            Default: =500
          Reset:
            PropertyKind: Input
            DisplayName: Reset
            Description: Custom Property
            DataType: Boolean
            Default: =App.ActiveScreen.Name = Parent.Name
          ShowModalDuration:
            PropertyKind: Input
            DisplayName: ShowModalDuration
            Description: Custom Property
            DataType: Number
            Default: =25000
        Properties:
          Height: =If(cmpAutoExit.InactivityTimerValue > cmpAutoExit.ShowModalDuration, App.ActiveScreen.Height,0)
          InactivityTimerValue: =timInactivity.Value
          OnReset: =Reset(timInactivity)
          Width: =If(cmpAutoExit.InactivityTimerValue > cmpAutoExit.ShowModalDuration, App.ActiveScreen.Width,0)
        Children:
          - timInactivity:
              Control: Timer@2.1.0
              Properties:
                AutoStart: =true
                BorderColor: =ColorFade(Self.Fill, -15%)
                Color: =RGBA(255, 255, 255, 1)
                DisabledBorderColor: =ColorFade(Self.BorderColor, 70%)
                DisabledColor: =ColorFade(Self.Fill, 90%)
                DisabledFill: =ColorFade(Self.Fill, 70%)
                Duration: =cmpAutoExit.MaxInactivityDuration
                Fill: =RGBA(56, 96, 178, 1)
                Font: =Font.'Open Sans'
                HoverBorderColor: =ColorFade(Self.BorderColor, 20%)
                HoverColor: =RGBA(255, 255, 255, 1)
                HoverFill: =ColorFade(RGBA(56, 96, 178, 1), -20%)
                OnTimerEnd: =Exit()
                PressedBorderColor: =Self.Fill
                PressedColor: =Self.Fill
                PressedFill: =Self.Color
                Reset: =ResetTimer And cmpAutoExit.Reset
                Start: =ResetTimer
                X: =20
                Y: =16
          - conBackGround:
              Control: GroupContainer@1.3.0
              Variant: ManualLayout
              Properties:
                Fill: =RGBA(0, 0, 0, 0.5)
                Height: =cmpAutoExit.Height
                Visible: =cmpAutoExit.InactivityTimerValue > cmpAutoExit.ShowModalDuration
                Width: =cmpAutoExit.Width
              Children:
                - conModal:
                    Control: GroupContainer@1.3.0
                    Variant: ManualLayout
                    Properties:
                      Fill: =RGBA(255, 255, 255, 1)
                      Width: =cmpAutoExit.ModalWidth
                      X: =(Parent.Width - Self.Width)/2
                      Y: =(Parent.Height - Self.Height)/2
                    Children:
                      - lblModalText:
                          Control: Label@2.5.1
                          Properties:
                            Align: =Align.Center
                            BorderColor: =RGBA(0, 18, 107, 1)
                            Font: =Font.'Open Sans'
                            Height: =Parent.Height-60
                            Text: =cmpAutoExit.ModalText
                            Width: =Parent.Width
                      - btnModalYes:
                          Control: Classic/Button@2.2.0
                          Properties:
                            BorderColor: =ColorFade(Self.Fill, -15%)
                            Color: =RGBA(255, 255, 255, 1)
                            DisabledBorderColor: =RGBA(166, 166, 166, 1)
                            Fill: =RGBA(56, 96, 178, 1)
                            Font: =Font.'Open Sans'
                            HoverBorderColor: =ColorFade(Self.BorderColor, 20%)
                            HoverColor: =RGBA(255, 255, 255, 1)
                            HoverFill: =ColorFade(RGBA(56, 96, 178, 1), -20%)
                            OnSelect: |-
                              =Set(ResetTimer,false);
                              Set(ResetTimer,true)
                            PressedBorderColor: =Self.Fill
                            PressedColor: =Self.Fill
                            PressedFill: =Self.Color
                            Text: ="Yes"
                            Width: =Parent.Width/5
                            X: =Parent.Width/5
                            Y: =lblModalText.Height + 10
                      - btnModalNo:
                          Control: Classic/Button@2.2.0
                          Properties:
                            BorderColor: =ColorFade(Self.Fill, -15%)
                            Color: =RGBA(255, 255, 255, 1)
                            DisabledBorderColor: =RGBA(166, 166, 166, 1)
                            Fill: =RGBA(56, 96, 178, 1)
                            Font: =Font.'Open Sans'
                            HoverBorderColor: =ColorFade(Self.BorderColor, 20%)
                            HoverColor: =RGBA(255, 255, 255, 1)
                            HoverFill: =ColorFade(RGBA(56, 96, 178, 1), -20%)
                            OnSelect: =Exit()
                            PressedBorderColor: =Self.Fill
                            PressedColor: =Self.Fill
                            PressedFill: =Self.Color
                            Text: ="No"
                            Width: =Parent.Width/5
                            X: =(Parent.Width/5)*3
                            Y: =lblModalText.Height + 10
    
     
     
  • Suggested answer
    Michael E. Gernaey Profile Picture
    53,323 Super User 2025 Season 2 on at
     
    Unfortunately you are asking for multiple things that a normal app won't do.
     
    1) if the apps are in multiple tabs, they won't gaurantee run anything when in the background, hence being on the tab
    2) You could use a timer, which would be easy, and you could simply trigger the Exit function on the timers run is over and that instance will go away
  • PP-21031328-0 Profile Picture
    2 on at
    @Michael E. Gernaey@BCBuizer Thank you so much for your replies. 
     
    Can please help me with the question.
     
    How can we identify particular canvas application is inactive? Is there any built-in functionality to identify that our canvas app is inactive?
  • BCBuizer Profile Picture
    22,505 Super User 2025 Season 2 on at
     
    There is no OOB option to know how long an app session is inactive. This is why I added a Reset property to the component in my previous reply which will allow you to reset the timer based on whatever trigger you determine in your app, for instance in the OnSelect property of buttons users are likely to use regularly.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard