This chapter illustrates how to use Power Apps
, Power Automate
, SharePoint
, and Teams together to solve real-world requirements. It is based on an actual COVID-19 notification application
. The gist of the design is that the decision-maker goes into a particular SharePoint list
and selects the current level (1–4) and adds any additional instructions. The level has a set of associated steps on restrictions such as whether personnel are on-site or remote. Whenever the status changed, there is automated post to Teams via Power Automate
with the summary and a link to a Power App
that displays the color-coded status and all the restrictions and instructions. We deployed the solution quickly with no licensing costs1 to rave reviews.
Configuration in SharePoint
Let’s start with the configuration of our data sources in SharePoint
. Figure 15-1 shows CovidStatusOptionslist
.
We give each status a Title (Level 1–4) and then a Color and TextColor (to be used later in Power Apps
). To avoid a “brittle” application that breaks if we rename our statuses, we make a numeric StatusNumbercolumn
as well.
Our next step is to use this as a lookup column for our CovidStatuslist
. As shown in Figure 15-2, we want to have access to the TextColor and Color columns as well as ID. So we include them as well.
Figure 15-3 shows the resulting list. It only has a single record with a title of Current Status.
In addition to the lookup Status column and its associated information, we have an AdditionalGuidance column where the senior leader updating the status can give specific information about current restrictions not generally associated with the Covid level. We make this column Enhanced rich text so that we can add formatting, graphics, etc., if needed. Figure 15-4 shows how the leader would edit the status and the additional guidance.
Our last SharePoint list
is CovidMitigationSteps, as shown in Figure 15-5.
This has the same Status lookup column, but we only bring along the ID column this time. We then list as many common steps (Dining Out and Remote Teaching in this example) as needed for each level. These and the Additional Guidance from Figure 15-3 will show up in the Power App
that we will cover next.
Creating the Status Application in Power Apps
We again create a Blank app ➤ Blank canvas app ➤ Tablet format in Power Apps
. Our next step is to connect to the CovidMitigationSteps and CovidStatus lists, as shown in Figure 15-6. We don’t need to connect to CovidStatusOptions since we brought its info over to CovidStatus via our lookup column.
Our next step is to display the current status in a label (Figure 15-7).
We use the fact that the CovidStatuslist
only has one record and use the First() method to grab the first item. We then read the Status column and its Value. Notice how Power Apps
shows us that this Value is text and is “Level 2.” More challenging is getting the Fill property, as shown in Figure 15-8. The tricky part here is getting from the text value of “Yellow” to the actual color of Yellow.
Luckily, Power Apps
has a ColorValue()method
just for this purpose. We read the first item of the CovidStatuslist
and then the Value of its Status:Color column and pass that to ColorValue() to convert it to a color2:
Since our Additional Guidance is rich text, we need to match that with an HTML text control,3 as shown in Figure 15-9.
Notice our formatted text comes over fine from SharePoint
and that we set the HtmlTextproperty
to our column value.
To display our steps from the CovidMitigationStepslist
, we use a Data Tablecontrol
. This allows us to show as many steps as needed and get a scroll bar if the list becomes longer than the space available. To get the steps associated with our current Covid Status, we filter such that the Status:ID columns match between the two lists:
As we have seen, the first parameter is the data source (CovidMitigationSteps) and the second is the logical test. Figure 15-10 shows the results.
Notice the delegation warning. This is because we are filtering by the non-primary lookup column values. Since there is a very limited number of statuses, we can safely ignore the warning in this case.
Configuring the columns of the data table is similar to working with galleries. As shown in Figure 15-11, we use the ThisItemsyntax
as in ThisItem.Text and ThisItem.Description.
Figure 15-12 shows the complete application with a final HTML text control with the phone number and a link to the Team and channel with additional information.
To get the link, we need to use our knowledge of HTML tags with   being a space, <strong> representing bold text, and the anchor tag (<a>) configuring a link.
We are not on our last task for posting to our COVID Response Teams channel whenever the status changes. We accomplish this via Power Automate
. We create an automated cloud flow with the trigger being whenever a list item is created or modified, as shown in Figure 15-13.
We choose our SharePoint site
and the CovidStatuslist
. We then create a CovidStatus variable and store the current Status Value in it. More significantly, we research into adaptive cards
and realize that the only valid color values in its JavaScript Object Notation (JSON)
are “default”, “dark”, “light”, “accent”, “good”, “warning”, or “attention”.4 Because of that, we will need to put one of these values in a new Color variable. Figure 15-14 shows connecting to the list and initializing both variables.
Note that we initialize the Color variable to one of our valid values – default. From there, we do a Switch condition on the Status:Color Value (Green, Yellow, Red, or Black) and set the Color variable to the associated string (good, warning, attention, or dark), as shown in Figure 15-15.
Again thinking ahead to the fact that the adaptive card
will want plain rather than rich text, we add an Html to text action for our AdditionalGuidanceand
then the Post adaptive cardin a chat or channel action. Both are shown in Figure 15-16.
Before we can configure our adaptive card
, we need to look at the available JSON formats
.5 Figure 15-17 gives an example.
We can copy this JSON
and then adapt it to our purposes. Listing 15-1 shows the edited version,6 with Figure 15-18 showing how it looks within Power Automate
.
Adaptive Card JSON
Incorporating COVIDStatus, Color, Additional Guidance, and the URL
Figure 15-19 shows the resulting adaptive cards
posted in the channel when we change the status twice.
Notice that even though we tell Power Automate
to use the Flow Bot, it still posts my name as the one who initiated the post (since it is my flow). That is not necessarily totally optimal, but it is good from a security standpoint. At least it has the Flow Bot graphic rather than my picture each time.
Summary
In this chapter, we put many of the key pieces together to build a complete application. We stored some key pieces of data in SharePoint and allowed leadership to edit that information there. Users viewed the data (with color-coding) via Power Apps
. They were prompted to do that by Power Automate
, triggered by changes to the underlying SharePoint data. The flow sent an adaptive card
with a link to the app to the specified Teams channel. This was very effective for pandemic response.