PowerApps Rocks!

Wheres the Code!?

For the uninitiated, locating the critical code within a PowerApp can be quite a source of frustration. Involving things like inheriting the code of others and non-standard code placement and even seasoned PowerVets reel at the thought of a full reverse-engineer in order to find everything.

In this post I'll give you the roadmap I wish I had when starting out. You'll be able to follow the steps below to locate all the critical code within a PowerApp.

The challenge

PowerFX functions (code) can be written on most control properties. (See Must-know PowerApps Definitions for help with these terms.). Developers, rookie and veteran alike, have free reign to choose the location of their code.


  • OnSelect property of a button control
  • OnChange property of a combobox control

As such, the more controls an app has, the more potential places there are for code to be written (and hidden!). There isn't a great way to "show me all the codez" in PowerApps, so you need a mental model of the way code should be laid out as a baseline.

First stop

OnStart of the App control is always the first stop in determining how a Powerapp works.

You should find some nice config code here. Not finding code here gives you some clues. It likely means the app is either very simple or perhaps made by someone new to PowerApps.

Second stop

OnVisible of the first screen of the app is the next logical point of code execution in a PowerApp.

Sometimes, the config code is located here instead of OnStart.

Third stop

If there are any call-to-action buttons or icons on the first screen, you'll likely find code placed on their OnSelect properties.

If you find functions like ClearCollect() here, the app was likely built a long time ago and hasn't been refactored for performance yet or was made by someone new to PowerApps. A best practice is to only GET data when loading the screen where data will actually be used.

Fourth stop

The call-to-action buttons/icons will likely take users to a different screen within the app. The OnVisible property of subsequent screens is the next likely location for code.

This is also a good place to put any ClearCollect() functions that will GET data to display to users on this screen. Stick with this just-in-time mindset for getting data and your users will be happy!

Check the controls

Nearing the end of our tour here, the next place to check for code is on the controls within each screen. Specifically the actionable properties such as:

  • OnSelect (anything; images, buttons, icons, dropdowns, labels, etc.)
  • OnChange (dropdowns, comboboxes, etc.)
  • OnCheck / OnUncheck (checkboxes)
  • OnAddFile / OnRemoveFile / OnUndoRemoveFile (Attachments control)

Inspect the properties of any control a user interacts with.

Check the forms and galleries

This is the last formal stop on the tour, but can sometimes hold the most complex code within a PowerApp.

Forms have some critical properties where code can be "hiding".


  • Item property
    • Points to the record the form will display
  • DataSource
    • Points to the data table a form is tied to
  • OnSuccess / OnFailure / OnReset (little devils!)
  • Default of each field within a form
  • Update of each data card in a form


  • Items property of gallery controls (FOCUS HERE!)
    • This property often holds the most complex Filter() logic in the entire app
    • Can get bananas when nested galleries come into play

Display properties and oddballs

PowerApps developers like to move things around the screen, shrink, animate, show, hide etc. These actions often involve the various display properties of a control.

These can get complex!

  • DisplayMode of each control in the app
    • Usually some home grown validation logic here
  • Height / Width / Visible and all other display properties of each control in the app
    • Devs get tricky with these properties!

A few oddballs that might present themselves...

  • DefaultSelected and DefaultSelectedItems of each combobox
    • Often a headache to understand.
    • So much so that Shane Young has a few videos on the subject!
  • HTMLText of all HTML Text controls
    • These are odd because of the flavor of HTML that PowerApps uses
    • Can get complex if formatted poorly

In closing...

A standard approach and placement of code goes a long way in maintainability.

Follow this little map to find code in PowerApps

  1. OnStart
  2. OnVisible of first screen
  3. OnSelect of any call-to-action buttons/icons on first screen
  4. OnVisible of subsequent screens
  5. Check all actionable properties of controls OnSelect, OnCheck, OnChange, etc.
  6. Check form and gallery properties Item, Items, OnSuccess, etc.
  7. Check all display properties of controls Height / Width / Visible, etc.
  8. Handle the occasional oddball~! DefaultSelectedItem, HTMLText, etc.


powerapps | standards |