Introduction
One challenge with canvas apps is that sometimes users don't have the latest version on their devices. Sure you can add a label for app version and ask app makers to update the number every time they open the studio, make a change, and publish the app. However, all of us forget to do that.
Version autonumbering
Here is a process to automate updates to the version number. Follow these steps:
- Create a table in your data source to store version numbers (could be Dataverse, SharePoint or any other data source).
- Add a new numeric column to store the version number.
- In the OnVisible of the 1st screen or in the OnStart of the app, check if the user is in the studio or not.
- You can find this out by checking if IsBlank(Param("tenantId")) is true or not.
- Count the number of rows in the table.
- If there are no rows, create a new one using the Patch function.
- If there is one, increment the version number by one and update that record.
- Add a label on the 1st screen to display the version number and the last modified on timestamp.
Here is the code:
Set(
gblIsAppInStudio,
IsBlank(Param("tenantId")) && IsBlank(Acceleration.X) && IsBlank(Location.Altitude)
);
If(
gblIsAppInStudio,
If(
CountRows('App Versions') = 0,
Patch(
'App Versions',
Defaults('App Versions'),
{
Name: "App Version",
'Version Number': CountRows('App Versions') + 1
}
),
Patch(
'App Versions',
First('App Versions'),
{'Version Number': First('App Versions').'Version Number' + 1}
)
)
)
Stay tuned for the remaining 4 tips!