Show or hide fields based on choice values in Power Apps

This post describes how to show or hide fields based on a choice column from a SharePoint list in Power Apps.

I was recently working on a Power App form for new site/ teams requests. The fields were all based on SharePoint list columns and one of the key fields was a choice column. What I wanted to do was have an additional field default to being hidden from the screen unless a particular choice value was selected.

Now I’ve used the Microsoft guidance to create dependant drop-downs before but this scenario was slightly different and it was based on a choice column which isn’t compatible to my knowledge. I’d done something before in my Power App to toggle the display mode of a button in my app if fields are blank. So starting with this I used a simple if function in my formula to show/ hide my field based on the selected choice value.

Solution

Here’s how to hide a field based on a choice value in Power Apps:

  • Open your Power App to edit it > ensure both the choice field and the field you want to hide are added to the screen
In this example, a drop-down list will be hidden by default until project site is selected from within the request type choice field.
  • Select the data card for the field you want to hide until a choice value is selected
  • In the top, left-hand corner of the Power Apps editor, select the visible property
Select the Visible property when selecting the hidden field in your PowerApp.
  • Add the following if statement to the formula bar, replacing the parts highlighted below:

If(rdoRequestType.Selected.Value="Project site",true,false)

  • Replace rdoRequestType with the name of your choice control
  • Replace “Project site” with the selected value from your choice field

Now, by default your field will be hidden from the screen until you select the relevant choice value!


Advertisement

Fun with PowerApps part 4: Creating a custom PowerApp

This is the final part in my fun with PowerApps series, in this post i’ll go through the steps involved in creating a new PowerApp from scratch and highlight some of the difference with using a template or generating a PowerApp from a SharePoint list.

You can read all the other parts in this series below:

Part 1: setting up the default gateway
Part 2: creating a data connection
Part 3: my first powerapp

Creating a PowerApp from scratch

So far we have generated our very first powerapp from a SharePoint list or library, but now we want to take it a step further and create a brand new PowerApp from the beginning to enable us to create a desktop experience.

To create the bespoke PowerApp we will need to begin in the PowerApps studio, the steps below walk through creating the bespoke PowerApp:

  • Navigate to https://web.powerapps.com/
  • In the Home screen, select Start from blank – make sure the desktop view is selected – Press Make this app

The PowerApps studio will give you some useful tips on how to create forms or galleries which are definitely worth checking out if you haven’t already!

  • On the canvas, press Connect to data
  • In the Data window, select the data connection we created earlier

  • Enter the URL of the SharePoint site you want to access
  • Once entered, you will see all the available lists and libraries you can use as the primary data source, select the one you wish to use

Conclusion

And there you are your custom PowerApp is all set up and ready to go! Of course this is just the very beginning and you now have the fun bits to come like adding all of the elements that will make up your PowerApp but from my experience I think there are a few approaches to achieve this.

My idea was to create and open up the template helpdesk PowerApp side-by-side with my custom one to get a better understanding of how to re-produce things like the totals across the top and some of the finer details that make up the PowerApp. I think doing it this way is much easier than trying to pick apart the templates as you are starting with your own data source rather than the static ones provided within the templates.

As well as the desktop and mobile experiences you now have the ability to create list forms using PowerApps too, so now there is even more fun to be had with PowerApps!

Source: https://docs.microsoft.com/en-us/powerapps/customize-list-form

Thanks for reading 🙂

Fun with PowerApps part 3: my first PowerApp

This is part three in my fun with PowerApps series where I’ll go through my personal experience of creating a new PowerApp from scratch and go through step-by-step for each part of the process…

You can read all parts of this series below:

Part 1: setting up the default gateway
Part 2: creating a data connection

Carrying on from my last post – creating a data connection, we are now good to go and begin to build our first PowerApp!

Just like setting up the data connection, creating a PowerApp can be a really simple thing to do.

However, I’ve found either creating a PowerApp from the SharePoint list or library is really quick and easy, but it doesn’t necessarily give you the most flexibility when it comes to wanting to do it your own way…

Creating a PowerApp

You can create a PowerApp from a list or library literally from the push of a button! Its as simple as:

  • Create your list or library, add all the associated columns and data you wish to be displayed in your PowerApp
  • Press the ‘PowerApps’ button on the list menu, then press ‘Create an app’

  • You’ll then be prompted to create your app, start by giving it a name and press ‘Create

After a few moments your app will be created! It will open in the PowerApps web editor and you should see your list columns and data displaying in your shiny new PowerApp!


You can also take a look at the app in the preview to get a good look at how it operates and how the data is displayed…

Conclusion…

That’s it! Your all set…but if you’re like me you’ll have some questions. Like, what if I want a desktop app and not a mobile one?

Well for that you’ll need to build an app from scratch, I’ll be going over creating a new PowerApp in the next part of this series so hold on as i’ll be posted the next part very soon!

Fun with PowerApps part 2: creating a new data connection

This is part two in my fun with PowerApps series where I’ll go through my personal experience of creating a brand new PowerApp from scratch and go through step-by-step for each part of the process…

You can read part 1 of this series below:

Part 1: setting up the default gateway

Continuing on from my previous post – setting up the default gateway, we should now be in a position to create a new data connection within PowerApps. On the surface this is pretty easy to do, all that’s needed is to choose the connection type – press create – authenticate – job done!

However, when we need to create a data connection for an on premise SharePoint environment, its a little bit of a different story. Here are the steps involved for setting up a new data connection for a SharePoint on premise environment:

  1. Go to web.powerapps.com
  2. Under Connections – press New Connection

  3. In the search bar, search for “SharePoint” – press the plus icon

  4. The SharePoint data connection popup box should appear, under “how do you want to connect to your data?” select Connect using on-premises data gateway
  5. Set the authentication type to Windows and then specify your username and password (you may need to include a domain name as part of the username)
  6. I used credentials of a user that had owner permissions for the SharePoint environment I connected to, it makes sense to me that the account you specify here would at the very least need to be able to read/write to the SharePoint list that acts as the data source.

  7. Choose the gateway we set up in part 1 of this series, if you can’t see it you might need to install it again or refresh the list until it displays.
  8. I actually had to create the default gateway using a different account than the one I created my first PowerApp with, so it wouldn’t show for me initially. I had to share the gateway I created and set my PowerApps user as an admin for it to show in this list.

  9. Press Save

You will now see your newly created data connection appearing in the connections list! Your able to edit and delete the data connection at any point and can also check who the owner is, the connection name and crucially the status of the connection under the details button.

BONUS

There is also this article from Microsoft talking through connecting to SharePoint from PowerApps that lists the known issues with certain column types:

https://docs.microsoft.com/en-us/powerapps/connections/connection-sharepoint-online

Fun with PowerApps part 1: setting up the default gateway

I’ve recently been playing with PowerApps for the first time, I set myself a challenge of creating an IT service desk in PowerApps using a SharePoint 2016 on premise environment as the main data source.

So before I start going through all the steps I found were needed for me to setup the default gateway, this article from Microsoft is a great place to start and contains most of the steps I’ll go through below:

Setting up the default gateway

  1. Download the gateway installer here
  2. Run and begin the install of the default gateway, this can be installed anywhere that is able to connect to the server name provided. Press Next
  3. Specify the install location for the gateway and accept the terms of use. Press Install

  4. Enter the email address you wish to use with this gateway. On the next screen of the wizard, press Sign in


  5. Select Register a new gateway on this computer, press Next


  6. Give your new on-premises data gateway a name, enter a recovery key and confirm it. Press Configure


  7. In the PowerApps Studio, under Gateways you should now see your Gateway listed
NOTES

I found that the internal firewall where I had setup the gateway was blocking connections, in my case the system admin allowed these connections and it worked a treat!

I also found that the 365 account used to register the default gateway needed a Power BI license assigned to it to be able to connect to a SharePoint on premise data connection.

I’m planning on doing a series of posts over the next few weeks on my fun with PowerApps so part 2 will be coming soon!