Maintenance mode and session expiration

When updating a canvas app and/or the underlying data model, you want to make sure nobody is actually using the canvas app at that time and that when the update is complete, only the new version of the canvas app and/or underlying data model is used.

Being able to put a canvas app in maintenance mode and having session expiration accomplishes just that. Maintenance mode makes sure that when someone starts a canvas app, (s)he will not be able to proceed. Session expiration ensures that after a certain amount of time, the canvas app cannot be used anymore.

Maintenance mode

There is no maintenance mode option in canvas apps but with a few simple steps, you can create your own!

The idea behind maintenance mode is the following:

  • When someone starts a canvas app, a variable is set which is used to determine if the canvas app should be in maintenance mode or not (Read: if a maintenance mode message must be shown or not). This variable can be hardcoded but this is not a recommended setup because the canvas app must be updated every time it must be placed in maintenance mode. The better way is to use an external settings table/list, retrieve the setting value and set the variable to that value.
  • A dialog which is on top of all other controls and spans the whole screen is shown when the canvas app is in maintenance mode. The dialog only shows text so the person starting the app cannot proceed.
  • The logic (code) only has to be implemented on the start screen.

Session expiration

There is no session expiration option in canvas apps but with a few simple steps, you can create your own!

1) First, create three variables which contain (i) the moment the session started, (ii) if the session is expired or not and (iii) the number of minutes after which the session must expire. Depending on your setup, this value can be hardcoded in the canvas app or placed in an external settings table/list. These variables must be set at app start (app control, property OnStart). Code example from sample canvas app:

Set(glb_SessionStart, Now());
Set(glb_SessionExpired, false);
Set(glb_SessionDuration, 60)

2) Create a container that spans the whole screen which will be shown when the session is expired. For this container, the property Visible must be set to the global variable glb_SessionExpired. A “Session expired” message must be shown.

3) Now, logic (code) as shown below should be added to the locations where you want to check for session expiration. This can be(come) many places in your canvas app. The logic checks if the session should expire and if so, show the container. Code example from sample canvas app:

UpdateContext({var_ButtonClick: Now()});
    ) > glb_SessionDuration,

If your canvas app has multiple screens with user interaction, you must add a container to all these screens.

Another important aspect is that the container should be the highest in the hierarchy of the controls so other controls cannot be clicked on. This also applies for maintenance mode.

An example canvas app has been created (export) in support of this blog post and is downloadable from my GitHub repository here.

A video in support of this blog post can be viewed on my YouTube channel here.

Please read a next blog post to make a better business solution: Disable your active OnSelect controls when showing a dialog

Useful URL(‘s)

Leave a Reply

Your email address will not be published.