Good canvas app naming conventions for variables and collections ensure their purpose is clear and understood.  A consistent and recognised format both helps the App Maker and assists other developers conducting a peer review or handover

naming conventions

The PowerApps Canvas App Coding Standards and Guidelines document was created some time ago and is a good starting point for consistency in all aspects of canvas app coding

Naming conventions can be an emotive subject and most developers have their own view on which format is best.  To a large extent, the naming convention itself is less important than making sure everyone in the team follows the same approach

In this post, I’ll explain the naming conventions for variables and collections that I now use and why I have chosen this format

Variables

I use a variable name to indicate the scope of the variable, the data type and its purpose

I also prefix the variable name with ‘var’ to easily distinguish it from collections and other controls

Variable Scope

Scope Use Abbreviation
Global
Every screen in the app
Gbl
Local
A single screen
Loc
Control *
Within a single specific control (created by the With function)
Ctl

* For an explanation of the With function and why I call the variables created using the With function as ‘control’ variables, see my post With Function: Creating a ‘Control Variable’

Variable Data Type

Variables can only hold a single data type and I use the following 3 letter abbreviations to represent them

Data Type Abbreviation
Text
Txt
Number
Num
Date
Dte
Boolean
Boo
Record
Rec
Table
Tbl

Variable Description

The description should define what the variable represents.  The wording should be simple, clear, written in camel-case and prefixed by an underscore

Examples

The variable’s type, data and purpose are all brought together using camel-case.  Below is a global variable that holds the user’s first name as text

varGblTxt_UsersFirstName

Further examples of variable names

varCtlNum_CreditScore
varLocBoo_UserApproved

Collections

A collection’s name should indicate the collection’s data source together with its purpose

I prefix the collection’s name with col to distinguish it from variables and other controls

Collection Data

Collection data can be generated from a connected data source such as Dataverse, or a temporary table created inside the Canvas App itself

Data taken from a persistent table is usually written back from the collection to it’s original source. Naming a collection to include the original source is helpful

I use the following 2 letter abbreviations for the most common data sources and for when the data is created within the app itself

Data Type Abbreviation
Dataverse
Dv
SharePoint
Sp
SQL Server
Sq
Azure Blob Storage
Bb
None (created in App)
Ap

Collection Description

The description should define what the collection represents.  The wording should be simple, clear, written in camel-case and prefixed by an underscore.  Because a collection usually contains multiple rows the description is usually written in plural

Examples

The data source and description are combined using camel-case to create the collection’s name

The example below is of a collection of invoices from Dataverse

colDv_Invoices

Further examples of collection names

colSp_Countries
colBb_DamagePhotos
colAp_NavigationItems

Summary

As I discussed in the intro, naming conventions can be an emotive subject and most developers have their own preferences

After using several naming conventions in the past (as you can see in previous posts), I’ve now settled on using the above notation for variables and collections as I find it the most descriptive and useful

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top