Showing posts with label Power Apps. Show all posts
Showing posts with label Power Apps. Show all posts

Wednesday, August 24, 2022

Powerapps form - Control field visibility using Sharepoint Groups

We in general create Sharepoint groups for any specific roles in a process and utilize them across the process for visibility / notifications etc.  As there is no direct way to check is a user is member of any specific Sharepoint group, we can follow below approach. 

1. Create a Sharepoint group and add required users for access. 

2. Create a Sharepoint List - PowerAppsAdmin and add Description column, along with existing Title

3. Add an Item to this list, 

      Title: "Custom App Admin Access" (Any relative name for easy reference)

      Description: Used in Powerapps form for Admin access fields (some details to understand easily on there its used)

4. Now remove  permissions on this list item and provide read access only to the above created sharepoint group, along with Owners group, if they are super admins.

5. In the PowerApps form, Add another data source  - above created Sharepoint List "PowerAppsAdmin"

Now the list and the data is accessible across the PowerApps. We can use this to control access or d isplay mode of fields / data cards using filter expressions, as in below example

6. Select Visible Property of a data card and write in below expression

not(IsEmpty(Filter(PowerAppsAdmin, Title = "Custom App Admin Access")))

The above expresssion is fitlering on the Admin lsit for an item with title we provided. If it is not empty, that means the logged in user has access to the list item and it implies the owner is an admin. So, the card will be visible to the user.

7. Same way, we can also control DisplayMode of the form be selecting Display Mode of the card and writing below expression

If(IsEmpty(Filter(PowerAppsAdmin, Title = "Custom App Admin Access")),DisplayMode.View,Parent.DisplayMode)

The above expression ensures if no record fetched, its always in view mode and for admins, the mode of field depends on form.






Saturday, June 13, 2020

Integrate Microsoft Flows with Power Apps

In this article we would go through the steps of Creating a Flow and integrating it with a PowerApps Form.

Though Power Apps doesn't has ability to call any web services / rest apis, it provided easy way to integrate with Flows, thus if we have any complex logic to be executed in the form, we can call a Flow with configured input parameters and the Flow executes the logic and provides response output parameters. 

Creation of  PowerApps Supported Flow
  • Create a Flow of type "Instant - from Blank" and in the trigger, select Power Apps,
     
  • Now, for any input parameter that required from PowerApps, click on any action and from Add Dynamic content window, select Ask in PowerApps from Manual section.
     
    We refer to as many input parameters we want and all would be in string.
  •  Build your logic using input values 
  • Finally, to respond back with output values, use Respond to a PowerApp or Flow action. This action would provide an ability to add any number of Output values of different types. 

  • Save the flow.
Creation of PowerApp and integrating the above Flow
  • Create an App or through any Sharepoint List, click on customize forms. I used Sharepoint list here
  • Select the Screen Control and go to On Visible property, in the function pane, click on Action tab and choose Power Automate. A subscreen pops up with list of available Flows. Click on the Flow we want to call.
     
  • Once we click on it, it adds a Method to call the Flow and it highlights shows the input parameters to fill in.
     
  • Here i set the output of Flow response to a variable and referred it in couple of label texts

  • Save the PowerApp and publish it. Once we load the form, we can see the responses on screen

Few important observations are as below
  1. Boolean output is not coming up in the PowerApp. Better we use string type and compare it
  2. For date field, PowerApps is considering as a string.
  3. On a high note, though we have different data types for output, if we want to sue in powerApps, better we use string type and convert them