PowerApps Form Logic

In PowerApps, once you get beyond the basics of customizing SharePoint list forms, or just using the out-of-box form control in your apps, the next common thing that people like to do, is add some logic to their forms.  In this post and associated video, I’ll demonstrate some of the most common things that are done with form logic, and how to accomplish them in PowerApps.   First of all, in PowerApps, we have a control called the “form control”.  If you have created your app as a customized SharePoint list form, you already have one screen with one form control on it.  If you’ve created a standalone app (which I highly recommend), the form control is something that you will be adding to your app.  See my other blog post about standalone apps versus customized list forms for more info about that topic.

Here’s a form control that I added to an app, arranged the cards like I want them to look, and added a big Submit button, and a lovely purple rectangle at the top.

powerapps-form-control-project

When creating logic in forms, this is usually done on each card.  Cards represent each field (column) in your SharePoint list or library.

Check out my Advanced PowerApps Course

powerapps-cards-on-form

Understand that there is a parent-child structure.  Cards can reference their parent (the form) and controls in a card can reference their parent (the card).

powerapps-controls-parent

Common Logic: Editable field according to condition

The display mode of a card can be set using the DisplayMode property, and here are some examples of what the 3 display modes look like, with a date picker control.

Edit:  The value can be edited by the end user filling out the form.

powerapps-display-mode-edit

View: The value is read-only

powerapps-display-mode-view

Disabled: The control is grayed out and read-only.

powerapps-display-mode-disabled

Side note: The way a control looks when it is disabled, can be controlled using any of the properties related to disabled controls.  Here, I did a search of properties for this date picker, in the advanced tab:

powerapps-properties-disabled-color

By default, each card inherits some of its parent’s properties.  DisplayMode is one of them.

powerapps-card-display-mode

Here’s how the logic works,with an example:

Goal:  Customer Status is read only for new forms.  My form is named frmNewCustomer.  First, unlock the card. (on the advanced tab on the right)

If the mode is new, THEN
DisplayMode.View
Otherwise
DisplayMode.Edit

powerapps-new-customer-form-formula

This second one is a little more advanced.  I added the Office 365 Users connector to my app, to gain insights about users.  For this logic, I’m assuming that if you have direct reports (based on user profile data) then that means you’re a manager, otherwise, you’re not a manager.

Goal: Customer Status is disabled if the current user is not a manager

IF the current user has no direct reports, THEN

DisplayMode.Disabled

Otherwise

DisplayMode.Edit

powerapps-user-manager-logic

Common Logic: Show / hide field according to condition

Every control has a Visible property, which is a boolean (true/false).  Logic can be used, to conditionally show and hide anything.

Goal: The hours used field should only show if the project status is complete.  My control that has a drop-down for project status has been named drpProjStatus.  This formula is placed on the visible property of the hours used card.

powerapps-hide-show-conditionally

project-status-change

Common Logic: Required field according to condition

Every card has a property called Required, which is a boolean (true/false).  Logic can be used, to conditionally make a field required.  Note that if this logic is used, make sure that the field is not set as “required” in the list settings in SharePoint.

Goal: If estimated cost is greater than $5,000, the manager field is required. This formula is on the Required property of the manager card.

powerapps-conditionally-required

Using those principles, and understanding how IF statements work, you’ll be able to built any logic that is needed in your apps.

Here is the video where I demonstrated these methods during Power Hour:

PowerApps form logic

Are you brand new to PowerApps, and interested in getting started learning some fundamentals?  Try out my

FREE 5 day PowerApps Beginner Email Course

Beyond beginner? Check out my full (12 hour) PowerApps advanced training class!

Leave a reply or question

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.