Skip to main content

Only show a control to an employee's manager in PowerApps (using SharePoint as a data source)

The Problem

In my previous blog post, I wrote a basic tutorial on configuring PowerApps to conditionally show/hide and make mandatory/optional a control based on the answer provided in a previous control.

In this blog post we will expand on that scenario to create a form that only shows a control called approval status to a user if that logged in user is the manager of the user specified in the employee control.

This means when the manager is using the application, they can change the status to approved. Meanwhile, a user that is not a manager of the person specified in the employee cannot change the status to approved.

The Solution

Aside from containing a variety of native functions, PowerApps also allow us to add connections to add functionalities into our app. In this case we will add the Office 365 Users connection so that we can get information on:
  • The user that is logged on
  • The manager of the user specified in the employee control
Note: Whilst this solution makes it difficult for non-managers to change the approval status, it does not prevent users from changing the status at the data level in SharePoint e.g. editing the out of the box SharePoint form or editing the list via datasheet view.

The Steps

The steps in this blog are also shown in the video below

The steps below shows a sample scenario of a expense request form
  1. In SharePoint Online, create a custom list called Expense Request
  2. Setup the following columns in the custom list
    1. Approval (Choice)
    2. Value (Number)
    3. Employee (Person)
  3. Create a new PowerApp connected to your Expense Request list
  4. From the ribbon, click on Content > Data Sources
  5. Add a new connection to Office 365 Users
  6. Click on the editable form page
  7. Click on the Employee control, and select advanced options on the right hand panel
  8. Note the configurations in the Display (e.g. Email is stored in Value1) and Update properties.

    This will help you determine what information to pass to the Get Manager functionality of the Office 365 Users connection
  9. Check out the Office 365 Users documentation from Microsoft to get a feel for the formula you would need to get the email of a user's manager, as well as the email of the currently logged in user
  10. Click on the Approval control, and select advanced options on the right hand panel
  11. Unlock the advanced properties
  12. Find the Visible property and populate it with the following formula

    If(Office365Users.Manager(DataCardValue6.Selected.Value1).Mail = Office365Users.MyProfile().Mail,true)

    Note: "DataCardValue6.Selected" is the same value that you would have seen in the Update property of the Employee Control. "Value1" on the other hand is where email is stored in the Display property of the Employee Control.
  13. Save your app

Testing the app

Click the play button on the top right to test out your app. You should see the following results
  • Log in as a manager of an Office 365 user
  • Enter the user that you manage into the employee control
  • You should see the approval status control appear
  • Change the user in the employee control to someone you don't manage
  • You should see the approval status control disappear

Next Steps

  • Have you created something similar using PowerApps? Please share your experience below.

Popular posts from this blog

An intro to conditional validation and formatting in PowerApps (using SharePoint as a data source)

The Problem What if we need to create a form that changes it's behaviour based on the answer entered by the user.

For example, we need to build a leave request form that: Shows the comment field if applying for a sick leave, but hides the comment field if applying for a annual leaveRequires the requestor to write a comment if their sick leave is more than 1 day, but is optional if sick for just 1 day.  The default form interface for custom lists in SharePoint Online can be used for basic scenarios, but doesn't provide an easy way to add business logic described above (unless you want to write some javascript)

In the past InfoPath would have been the tool of choice for many, however this tool is now in maintenance mode and whilst it will still be supported for a wee while there will be no improvements or enhancements to the platform.

The Solution This is where PowerApps come in. PowerApps is now the platform that is recommended by Microsoft as a way for business users to create…

Uploading a file from a SharePoint document library into an Azure Blob Storage with Microsoft Flow (or Logic App)

The Problem One of the things that I've been experimenting with lately is Microsoft Flow. The service allows you to build process automation to facilitate transfer of information from one system to another easily.

One scenario I wanted to try out is to be able to copy/move a file from SharePoint to an Azure Blob Storage. There are a number of reasons that you may want to do this:

Archive files that are no longer neededUpload a copy of a file (usually an image) into a Blob Storage so that images can be hosted in a CDN to optimize page load performance In the past doing something like this would have required some form of custom development e.g. a remote event receiver. However the introduction of Microsoft Flow and Logic Apps has created another alternative that is worth exploring....

Update 30/09/16: If you are looking to put your assets into a CDN to make it load faster, then it's worth checking out the new Preview Release Office 365 Public Content Delivery Network (CDN) capab…