COVID19 Building Access App: Per Space Approval

This week I’ll start a series on incorporating changes into the COVID19 Building Access App. The first post will show how to change the 1.1 version to include per space approval.

By default the Building Access App includes an approval process that can be automatic, based on the manager configured on Active Directory or through a post into a specific Teams channel with adaptive cards for those users that don’t have a manager configured.

The number one request I get from customers deploying the app for the back to office scenario is to have the ability to have specific users responsible for specific spaces.

The following instructions can be used to learn about the application, power apps or even to incorporate the feature in your implementation. Please be aware that those changes only work in the 1.1 version of the app.

If you don’t want to follow the steps to change your setup and just need the feature in your environment, I published a new package on GitHub with the required changes already incorporated into the 1.1 package. I versioned it as 1.11.  

https://github.com/cristianoag/BuildingAccess/releases/tag/1.11

20200811_113400000_iOS20200811_113313000_iOS20200811_113304000_iOS20200811_113320000_iOS20200811_113335000_iOS

Here are the changes that need to be implemented.

SharePoint Online

The first step consists on the creation of two additional columns on the BAR_Spaces SharePoint list to store space approvers and the flag to override the default approval flow.

  • Open SharePoint Online as administrator. Open the SPO site being used to store data for the BAR application.
  • Create an additional column of type person (Approver) in the BAR_Spaces SharePoint list.
  • Create an additional column of type Yes/No (HasApprover) in the BAR_Spaces SharePoint list. Select the default value No.

Building Admin

Now you need to update the Building Admin app to incorporate changes into the spaces detail form as well as in the gallery used to present spaces for configuration.

  • Open PowerApps as admin and edit the Building Admin app.
  • Go to Data and refresh the BAR_Spaces connection.
  • Go to Tree view and expand the Screen Space Detail page, click FormEditSpace, select Edit Fields and include the Approver and HasApprover additional fields. Change properties as required.
  • Select the DataCardValue in HasApprover (switch) and update the OnCheck event with:
Set(b_hasapprover,true);
  • Select the DataCardValue in HasApprover (switch) and update the OnUncheck event with:
Set(b_hasapprover,false);
  • Select the Approver Datacard and replace the value for Visible by b_hasapprover
  • Go to Tree view and expand the Screen Spaces page.
  • Edit GallerySpaces and include an additional label with the text “Approver:”. Make the font weight Samibold on properties.
  • Still on GallerySpaces, include an additional label connecting Text to the following formula:
If(ThisItem.HasApprover,ThisItem.Approver.DisplayName,”Default”)
  • Save and publish the app.

Building Access

The main app needs to be changed to pass the appropriate parameters to the request creation flow.

  • Open PowerApps as admin and edit the Building Access app.
  • Go to Data and refresh the BAR_Spaces connection.
  • Go to Tree view and expand Screen Availability. Expand GallerySpace and select imgAddRequest_1.
  • In the Action pane, go to OnSelect and change the content to include two additional parameters to the colChosenRequests collection. The content needs to be changed.
From this:

Collect(colChosenRequests,{FloorID:ThisItem.ID,BuldingID:ThisItem.BuildingID,DateValue:varSelectedDateString ,FloorTitle:ThisItem.Title,DatePickerValue: DatePicker.SelectedDate,BuldingName:varSelectedBuilding.Title, FloorName:ThisItem.Title,BuildingMaxOccupancy:Value( varSelectedBuilding.MaxOccupancy) ,RequestorName:varUser.displayName,RequestorEmail:varUser.mail,

OverCapacity:If( (CountRows( colDateRequests) >=varSelectedBuilding.MaxOccupancy) || varSelectedBuilding.MaxOccupancy = 0,true,false)

}) ;

UpdateContext({btnAddRequestInfoVisible:true});

//Notify(varString.RequestAddedPopupMsg,NotificationType.Success,3000)

To this:

Collect(colChosenRequests,{FloorID:ThisItem.ID,BuldingID:ThisItem.BuildingID,DateValue:varSelectedDateString ,FloorTitle:ThisItem.Title,

FloorApproverEmail: ThisItem.Approver.Email,

FloorHasApprover: ThisItem.HasApprover,

DatePickerValue: DatePicker.SelectedDate,BuldingName:varSelectedBuilding.Title, FloorName:ThisItem.Title,BuildingMaxOccupancy:Value( varSelectedBuilding.MaxOccupancy) ,RequestorName:varUser.displayName,RequestorEmail:varUser.mail,

OverCapacity:If( (CountRows( colDateRequests) >=varSelectedBuilding.MaxOccupancy) || varSelectedBuilding.MaxOccupancy = 0,true,false)

}) ;

UpdateContext({btnAddRequestInfoVisible:true});

//Notify(varString.RequestAddedPopupMsg,NotificationType.Success,3000)

  • Save and publish the app.

BARCreateRequests Flow

The BARCreateRequests flow needs to be changed to update the appropriate parameters in the request.

  • Open Power Automate as admin, click My Flows and edit the BARCreateRequests flow.
  • Expand InputRequests and change the schema to include FloorApprover (string) and FloorHasApprover (boolean) input parameters.

From:

{

“type”: “array”,

“items”: {

“type”: “object”,

“properties”: {

“BuildingMaxOccupancy”: {

“type”: “number”

            },

“BuldingID”: {

“type”: “integer”

            },

“BuldingName”: {

“type”: “string”

            },

“DatePickerValue”: {

“type”: “string”

            },

“DateValue”: {

“type”: “integer”

            },

“FloorID”: {

“type”: “integer”

            },

“FloorName”: {

“type”: “string”

            },

“FloorTitle”: {

“type”: “string”

            },

“OverCapacity”: {

“type”: “boolean”

            },

“RequestorEmail”: {

“type”: “string”

            },

“RequestorName”: {

“type”: “string”

            }

        },

“required”: [

“BuildingMaxOccupancy”,

“BuldingID”,

“BuldingName”,

“DatePickerValue”,

“DateValue”,

“FloorID”,

“FloorName”,

“FloorTitle”,

“OverCapacity”,

“RequestorEmail”,

“RequestorName”

        ]

    }

}

To:

{

“type”: “array”,

“items”: {

“type”: “object”,

“properties”: {

“BuildingMaxOccupancy”: {

“type”: “number”

            },

“BuldingID”: {

“type”: “integer”

            },

“BuldingName”: {

“type”: “string”

            },

“DatePickerValue”: {

“type”: “string”

            },

“DateValue”: {

“type”: “integer”

            },

“FloorID”: {

“type”: “integer”

            },

“FloorName”: {

“type”: “string”

            },

“FloorTitle”: {

“type”: “string”

            },

“FloorApproverEmail”: {

“type”: [“string”, “null”]

            },

“FloorHasApprover”: {

“type”: “boolean”

            },

“OverCapacity”: {

“type”: “boolean”

            },

“RequestorEmail”: {

“type”: “string”

            },

“RequestorName”: {

“type”: “string”

            }

        },

“required”: [

“BuildingMaxOccupancy”,

“BuldingID”,

“BuldingName”,

“DatePickerValue”,

“DateValue”,

“FloorID”,

“FloorName”,

“FloorTitle”,

“FloorHasApprover”,

“OverCapacity”,

“RequestorEmail”,

“RequestorName”

        ]

    }

}

  • Expand Scope-CreateRequest. Expand ForEachRequests and create a Get User Profile step just before the CreateRequests step. Use the formula below for the UPN value.

if(items(‘ForEachRequests’)[‘FloorHasApprover’],items(‘ForEachRequests’)[‘FloorApproverEmail’], if(variables(‘varManagerExists’),body(‘Get_manager_(V2)’)?[‘mail’], variables(‘UserEmail’)))

  • Expand CreateRequests. Update the formula for ApproverNameText to:

if(items(‘ForEachRequests’)[‘FloorHasApprover’],body(‘Get_Space_Approver_Profile’)?[‘displayName’],

if(equals(variables(‘varManagerExists’),true),body(‘Get_manager_(V2)’)?[‘displayName’],”))

  • Update the formula for ApproverGuid to:

if(items(‘ForEachRequests’)[‘FloorHasApprover’],body(‘Get_Space_Approver_Profile’)?[‘id’],

if(equals(variables(‘varManagerExists’),true),body(‘Get_manager_(V2)’)?[‘id’],”))

  • In Approver, Update the formula for Claims to:

if(items(‘ForEachRequests’)[‘FloorHasApprover’],items(‘ForEachRequests’)[‘FloorApproverEmail’], if(equals(variables(‘varManagerExists’),true),body(‘Get_manager_(V2)’)?[‘mail’],null))

  • Save the flow and test the application. It should be able to deal with all approval cases, including approval per space.

Leave a Reply

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