Send One Email per Person in a Mixed List

apply to eachOne of the most common questions I see on the Power Platform forums is: “I have a data source that contains a list of information that I need to send as an HTML table to the individual mentioned in each item. But its sending more than one email to each person.  How do I get it to send just one email for each person with all the records for that person?”  In this post I’ll demonstrate a general method to accomplish that goal using Power Automate. For this example we’ll use a simple list from SharePoint, but the same technique should work for any data source that can be sorted.  Here’s our list:

list

We want to send a table with the hours spent by each programmer and their current status to each Project Manager.

Step#1 – Retrieve the records from data source.  Sort them based on the field that references the person, in this case Project Manager. This will not work if the field includes multiple people. Here’s a screenshot of that part of the flow.

list1

Step#2 – The next step is to get a list of the distinct project managers in the results we have retrieved.  Unfortunately, Power Automate doesn’t have a Distinct() function.  But we can achieve the same result using a combination of a Data Select action and the Union() function. When we combine the Data Select array with itself using Union() we will get an array that has a single instance of each unique record in the Data Select array. In this case a list of each Project Manager’s Email address.

Distinct1

Step#3 – Now that we have an array of distinct Project Manager Emails we can run an Apply to Each loop on each Email, extract the records for that manager, create a table and send the email. Here’s what the overall Loop looks like then we’ll review each step. The loop runs on the array produced by the union in the last Compose action.

loop 1

Loop Step #1 – The first thing we do inside the loop is filter the original set of records to create an array of records where the Project Manager’s Email in the record matches the current item’s email.  Since we stored the email as a record using the data select we need to retrieve it using JSON notation in the Expressions tab.  The JSON will be for the current loop item ‘PM’ property.  items(‘Apply_to_each’)?[‘PM’]

apply1

Loop Step#2 – Now that we have the records for one of the Project Managers we need to turn them into a table. First we need to use Parse JSON to re-apply a schema to the filtered records so we can access individual columns.  We parse the Body output of the filter array action. Run the flow once after adding the Parse JSON and use the output from the filter array to generate a JSON schema.

apply2

Loop Step#3 – Now we are ready to create the HTML table to embed in the email. Use the Create HTML Table set for custom and map the columns you want in the table from the Parse JSON output. I used the programmer’s displayName, Hours, Status, and Project columns. You may have multiple columns with the same name, like DisplayName.  These represent the embedded properties in objects.  For example the DisplayName might be for the Project Manager, the Programmer, or the person who created the item in the list. You can tell which one you added by hovering over the column and looking at the JSON.

apply3

Loop Step#4 – The last step in the loop is to send the email. Use the same JSON that you used to filter the array in Loop Step#1, since that is the email address of the Project manager. Fill out the subject and Body of the email with whatever information you want, including the HTML table you just created.

Apply4

That’s all you need.  The loop will now process each Person in the list and send one email to each with the correct information. I’m sure your list will be different, but the steps should be essentially the same.

NACS 2019 – Wrap up and Slides

The North American Collaboration Summit (NACS) concluded last weekend in Branson, MO. This is one of the great small SharePoint conferences in the US and I always look forward to attending. It fell again this year on the weekend before the MVP Summit in Redmond at Microsoft, so travel arrangements were complex.  But it was well worth the effort. Most of my sessions were well attended and the one highly technical session that had a low turnout probably had the highest interest from the attendees who were there.  It was a pleasure to feel that I was sharing information that people really wanted to learn about.  It was also great to spend time with a number of long time friends who were also presenting.

I promised to make my slides available, so I’ve uploaded them here.  Sorry for the delay, but getting anything extra accomplished while at the MVP Summit is almost impossible. If you have any follow-up questions please email me at pstork@dontpapanic.com.  You can download a copy of the slides from each talk using the links below:

Intro to SharePoint 2019: What’s New

Desired State Configuration (DSC): Controlling SharePoint Deployment in Azure VMs

Intro To OneDrive NextGen Sync: What is it, how it works, and can I manage it?


Filter on a Boolean in PowerApps

PowerappsOne of the spots where I see a lot of people being challenged when they first learn PowerApps is the concept of delegation. Delegation comes into play when working with data sources larger than 500 records. By default PowerApps is designed to only work on a maximum of 500 records at a time. You can increase this default setting to a maximum of 2,000, but that usually results in a noticeable performance lag in your PowerApp. To avoid that problem you should always limit the number of records you are retrieving from a data source to 500 records or less. One of the most common ways to do that is by using the Filter() function to limit the records being returned by the data source to a specific subset that you want to work on.

Using Filter() to limit the number of records retrieved from a specific data source is a great strategy, but it doesn’t always work. This is where understanding the concept of delegation becomes critical. Delegation is the process of having the data source filter the records before they are returned to the PowerApp instead of having the PowerApp apply the filter directly. This is complicated by the fact that not all data sources support delegation and different data sources support different logical operators for delegation. You can find a list of delegable data sources and operators here: https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/delegation-list. But even this documentation can lead to confusion.

The confusion comes in from some footnotes in the ‘Filter and LookUp delegable predicates’ section of the documentation. Footnote 3 on the logical operators reads, “For numeric columns, all operators can be delegated. For ID columns, only the ‘=’ can be delegated. Date columns can’t be delegated.” This would imply that all the operators should work with a Boolean value of true or false. But in my experience Boolean columns are treated the same way that ID columns are treated. The only operator that works is ‘=’. If you try to use a Filter statement where a Boolean value is not equal to something you will see that it issues a delegation warning. The following screenshot shows an example.

PowerApps1Blog

But if I change the formula to the Boolean being equal to true then the delegation warning goes away and the function becomes delegable. See the screenshot below.

PowerApps2Blog

The moral of the story is that understanding the intricacies of delegation is critical when building PowerApps.

Re-awarded as an MVP for the 11th Year

MVP_Logo_Secondary_Blue288_RGB_300ppiFor the last 10 years July 1st has always been a day that I both looked forward to and dreaded.  I’ve looked forward to it because its anniversary of the day that I was awarded the honor of being named as a Microsoft Most Valuable Professional for the first time. But I’ve also dreaded it.  Because no matter how many presentations you’ve made or how much you’ve answered questions on the forums or active you’ve been in the community, you always wonder if its been enough. But then sometime around mid-day the email arrives saying that you have been re-awarded for another year as an MVP.  That email arrived for me today around 11:40 AM (9:40 AM Redmond time). So for the 11th year Microsoft has decided that my contributions to the SharePoint and Office 365 community were sufficient to earn  me an MVP award again for the category of “Office Servers and Services”. 

But this coming year will be a little different than previous years because I plan to move towards partial retirement from my consulting career. Before you get the idea that I’ll be less involved as an MVP, think again. Being an MVP has always been about your contributions to the technical community over and above your regular job. So in the past I often took vacation time to speak at conferences or spent time on the forums before and after work.  Since I won’t be focusing on “earning a paycheck” anymore I’ll be able to devote even more time to community activities. I’m expecting my contributions to the community will go up as I move to retirement, not fade away.

So, I make this offer to Community Leaders

If you are looking for a SharePoint or Office 365 speaker for your event, and you can help me defray travel expenses, I will be willing to travel almost anywhere, at anytime to share what I have learned over the years.

SharePoint, Office 365, and Dynamics CRM are subjects that I’m passionate about. And my moving towards retirement is just a partial thing. I still plan to continue to do consulting and training for many years to come. If consulting/training opportunities come my way I will continue to work. Because that’s now I keep learning new things. But if paying jobs don’t happen to come my way then I’ll live off my retirement savings and spend even more time speaking and answering questions. 

So here’s to another year as an MVP. I think it will be an exciting one.

SharePoint Saturday – Cincinnati

SPSCincinnatiI had a small but enthusiastic group at my session this past Saturday at the SharePoint Saturday Cincinnati event. We had an excellent discussion about the planning that organizations should do before they implement or upgrade a SharePoint environment.  I promised attendees that I would post my slides by today before I got busy with other things.  You can find a link to the session below…

Implementing SharePoint: Failure to Plan is Planning to Fail (Slides)

One of the most common mistakes I’ve seen clients make when implementing SharePoint is to not spend enough time review a list of seven planning topics that are critical to the success of every SharePoint project. We’ll review what questions you should ask and why each area is critical to project.
The seven areas include:
• Governance
• Security
• Content Classification (Taxonomy/Folksonomy)
• Physical and Logical Architecture
• High Availability/Disaster Recovery
• Staffing
• Training/Communications