cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Combining multiple Compose actions into a single array ignoring null values

Hi all,

 

I have a form which contains a multiple answer response. In order to use the individual answers from this response, I have setup multiple (approx 20) compose actions containing if functions to extract each answer if they appear in the form response array.

 

What I am now trying to do is combine these into seperate arrays to email various members of my team if they are responsible for that action.

 

For example, Bob may be responsible for all forklift training requests. In the form response, I want to use the compose actions relating to forklift training and combine these into an array to send Bob an email for him to arrange the training. 


However, there wont always be a value in the compose action so I only want to combine the compose steps that have a value, and ignore the nulls completely.

 

Can anybody help?

12 REPLIES 12

First, I would not use 20 Compose steps, mainly because it is confusing when trying to put the values elsewhere in the flow. If you had to do it like that, I would replace each one of the Compose with an Initialize Variable as String and then use those variables elsewhere around the flow. So you can individually name each variable and it appears in the Dynamic Content options and other steps with the name.

 

Even then, I don't think I would use 20 variables. That is trying to deal with too many things.

 

You should design the flow so that it deals with the different things with the same steps. So I would start by putting the question responses into a single array, and then Apply to Each on that array.

 

So for each training type they select do actions to that value. This is where you might have to use a Switch or Conditions.

 

Here is a quick example showing putting the multi-choice response into an array. 

Form QuestionsForm QuestionsExample to put multi-choice response into array.Example to put multi-choice response into array.Example Results each training is a single Apply to Each item.Example Results each training is a single Apply to Each item.

 

Could you think about the process and what you want to accomplish by using this method instead of 20 separate Compose steps?

 

 

 

 

Thanks for the response. I was hoping that somebody would highlight how silly my solution was because it seemed very long winded. I just couldnt think of another way!

With this solution, how would I then seperate the individual answers.

 

For example, if Bob was in charge of chain saw & airplane training and Dave was in charge of forklift and crane? I need to construct an email with a list of the training requirements per response.

That is where you would use a Switch or Condition to break off what steps you want to happen. It also can depend on how you are getting Bob and Dave's email into the flow.

 

Here is a simple Switch and in each Case is where you would format an email for the training type. (Note that if Bob is Forklift and Crane trainer. And the form response contains Forklift and Crane training, then Bob would receive an email as Forklift trainer and then a second email as Crane trainer since this is acting on each response value.)

Example SwitchExample Switch

 

You could have up to 25 cases in a Switch. And the Equals value in the case must match exactly to the value that will be compared to in the Switch.

 

Thanks. 

 

That switch function is just going to end up with 20 steps with 20 seperate emails isnt it?

 

I need to combine them into one email based on who is responsible so maybe this isnt a solution that will work

It doesn't have to be exactly like this.

 

I just wanted to show you that it will be better to put the responses into a single array and manage them like a single object. That was the initial question of your post.

 

If you want to work on a full solution, you need to describe a plan of all the things you have and are trying to do in detail. Such as data sources, how many trainers, what are other form questions, are you putting data into a list, email body differences? Show what you have built and what all you need.

 

Really would need to know more about the trainers, I don't know if you have 40 people needing notifications based on groups of trainings? How are these grouped? Is there a source of this trainer roster?  

Thanks again,

 

These will be grouped by either HR organising, or Line Manager organising. 

 

There is no source for these so I am aiming to manage the distribution in the flow. The ideal for me would be that once the responses are seperated I am able to put 2 arrays together based on which courses are managed by HR and which are managed by Line Manager.

 

In your example, I would want to use the outputs from your steps to send 1 email to Bob with ALL training courses he is responsible for, and 1 email to Dave with ALL training courses he is responsible for. 

 

I can setup an excel spreadsheet to allocate the training courses if it makes it more straight forward?

Yes that visual would be very helpful.

Hi.

 

These are the courses and the responsibilities. 

 

Gwill1983_0-1691744208795.png

 

I like the way the flow is working currently with the array being seperated, but unsure how I can then group those individual outputs based on the responsibility rules to construct an output that can be used in an email. 

 

 

Could you just have 2 form questions to select training instead of 1? All manager training in one question, and all HR training in another question? Then you could easily email one or the other based on which questions had responses.

 

Otherwise all of those courses are going to have to be written into the flow or pulled from a reference sheet each time so that it knows where to check and send an email. I can do this too, but then you are trying to manage matching a reference source instead of simply changing the form questions.

Unfortunately not. It would be too confusing for the end user as it is part of a very large form. 

 

I believe I have found a way to do this using the multiple compose actions as previously. I have put them all into a Scope so that it doesnt swamp the flow and have created a array for each based on which courses are organised by each. 

Had to do a bit of format tidying etc, but it does work. 

Not very dynamic if more options are added in future so not ideal!

 

Give me a minute and I'll try to make something easier.

Ok here is an example flow. The key is making two initial Arrays that will hold the list of courses each for Line Managers and for HR.

The question response is put into an array like it was previously, but now the individual item is compared to the Line Manager course list and the HR course list to see if it is included. Basically does it match any of the courses listed in either.

 

Then there are two more arrays that are like lists that will be used for the emails. When the item is compared to the source arrays and matches, then it will be added to that email list. 

 

Then the email lists are formatted as HTML tables and inserted into the emails.

 

A couple of notes:

  • This will run if the question is blank. But don't worry about that now. I didn't want to clutter this example up more than necessary. You could easily insert another condition before sending either of the emails to see if the EmailListArray it has items or not. So yes or no send an email.
  • I have made two separate conditions in order to compare the response to the course lists. So it is being compared to both. You could change this condition or even delete one since it would basically be if it doesn't match one then obviously it matches the other. However, I created separate conditions so it is more transparent and it could help identify question texts that are incorrect or not matching either the source course lists. 

Here is an overview of the questions from the form and overview of the flow:

Form QuestionsForm QuestionsFlow OverviewFlow Overview A summary of the flow:

  • Get Response Details
  • Initialize Line Manager Course Array that holds source list of courses assigned to Line Manager.
  • Initialize HR Course Array that hold the source list of courses assigned to HR.
  • Initialize Form Response Array that will have the form question responses put into the MultiResponse Array.
  • Initialize two variables array that are blank and will be used later:
    • Email Line Manager Array - used for the Line Manager Email
    • Email HR Array - used for the HR Email
  • Compare each value in the MultiResponse Array to the 2 source course arrays.
    • If the value matches a course in the Manager list, then add that value to the Email Line Manager Array.
    • If the value matches a course in the HR list, then add that value to the Email HR Array.
  • Compose - HTML Table Style is just code that makes the email look better, you can format it with CSS
  • Create an HTML Table for Line Manager - this uses the Email Line Manager Array
  • Create an HTML Table for HR - this uses the Email HR Array
  • Send Emails to Manager and HR with their tables. Insert the Compose HTML Style before each HTML table in the email body.

Here are detailed screenshots of the flow:

Flow Detail 1 - Create Source ArraysFlow Detail 1 - Create Source Arrays

 

You have to manually put in the courses and be sure that the names match the responses in the MS Form exactly. (This could be replaced with a SharePoint or Excel source list)

 

Here is my LineManagerCourses Array you can copy and paste:

 

[
  "Caliq Overview",
  "Caliq Sales Ordering Processing",
  "Working at Height - Construction",
  "Ladder Training",
  "IPAF",
  "PASMA",
  "Site Management Safety Training",
  "Site Supervisor Saftey Training (SSSTS)",
  "Construction Skills Certification Scheme (CSCS Card)",
  "Forklift Driver - Counter Balance",
  "Forklift Driver - Reach Truck",
  "First Aid at Work (3 Day Course)",
  "Zoho Training"
]

 

 

Here is the HR Course Array you can copy and paste:

 

[
  "Working at Height - Basic",
  "UKATA Asbestos Awareness",
  "CDM Awareness",
  "Occupational Driver Training",
  "Driving for Business",
  "COSHH - Dangerous Substances",
  "Emergency First Aid at Work (1 Day Course)"
]

 

 

I used your Excel list as a reference, but I did capitalize all of the words, so if your form is different you need to change those values.

There is a double space before each course name that is in "quotes" and a comma afterwards. Do NOT put a comma after the last course name (I always forget to remove the last comma and it makes an error).

 

Here is the step that puts the response question into an array no different than one of the previous post examples:

Flow Detail 2 - Create Response ArrayFlow Detail 2 - Create Response Array

 

Here is where the values of the Form MultiResponse Array is compared to each of the source lists. Then if it matches it is added to the corresponding email array.

Flow Detail 3 - Compare Response to Course ListsFlow Detail 3 - Compare Response to Course Lists

Adding Zoomed Photos of the Apply to Each Conditions:

Flow Detail 3 Zoom 1Flow Detail 3 Zoom 1Flow Detail 3 Zoom 2Flow Detail 3 Zoom 2

 

This is the HTML Table Style code. This will be used for both email tables. It doesn't have any specific value reference within the flow and stays the same no matter what else you change. There is a good explanation about CSS Table Formatting at this link

 

Flow Detail 4 - Format CSS STYLEFlow Detail 4 - Format CSS STYLE

 

Just copy and paste this into your flow: (I copied it from this example and removed the width 100% line.)

 

<style>
table {
  border: 1px solid #1C6EA4;
  background-color: #EEEEEE;
  text-align: left;
  border-collapse: collapse;
}
table td, table th {
  border: 1px solid #AAAAAA;
  padding: 3px 2px;
}
table tbody td {
  font-size: 13px;
}
table thead {
  background: #1C6EA4;
  border-bottom: 2px solid #444444;
}
table thead th {
  font-size: 15px;
  font-weight: bold;
  color: #FFFFFF;
  border-left: 2px solid #D0E4F5;
}
table thead th:first-child {
  border-left: none;
}
</style>

 

 

Now you use the Create an HTML Table and the arrays that you inserted values into when using the conditions: 

Flow Detail 5 - Create HTML Table and EmailFlow Detail 5 - Create HTML Table and Email

 

Put the CSS Style output directly in front of the Create HTML Table in the email to apply the style to that table.

 

Below are the Email results if every option was selected in the form.

Email ResultsEmail Results

 

I think this is a good method because you can easily match the form questions to lists in the flow. You could replace the manual array lists with an Excel or SharePoint source list with a couple of extra steps and the flow would remain the same. (Basically you would List Rows or Get Items for Manager courses and put it into the array instead of typing, and then you would have a second List Rows or Get Items for HR courses and put it into the array for HR.)

 

Dealing with a non-response just requires adding conditions before you create the emails. The condition would check if the EmailLineManagerArray is equal to empty() and if so then don't send an email or whatever. Same goes for adding a condition to check if EmailHRArray is equal to empty() if so then don't send an email.

 

Try to put this together and let me know if it works for you,

 

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!    This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Community MembersNumber SolutionsSuper UsersNumber Solutions Deenuji 9 @NathanAlvares24  17 @Anil_g  7 @ManishSolanki  13 @eetuRobo  5 @David_MA  10 @VishnuReddy1997  5 @SpongYe  9JhonatanOB19932 (tie) @Nived_Nambiar  8 @maltie  2 (tie)   @PA-Noob  2 (tie)   @LukeMcG  2 (tie)   @tgut03  2 (tie)       Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 2: Community MembersSolutionsSuper UsersSolutionsPower Automate  @Deenuji  12@ManishSolanki 19 @Anil_g  10 @NathanAlvares24  17 @VishnuReddy1997  6 @Expiscornovus  10 @Tjan  5 @Nived_Nambiar  10 @eetuRobo  3 @SudeepGhatakNZ 8     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 3:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji32ManishSolanki55VishnuReddy199724NathanAlvares2444Anil_g22SudeepGhatakNZ40eetuRobo18Nived_Nambiar28Tjan8David_MA22   Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Week 4:Community MembersSolutionsSuper UsersSolutionsPower Automate Deenuji11FLMike31Sayan11ManishSolanki16VishnuReddy199710creativeopinion14Akshansh-Sharma3SudeepGhatakNZ7claudiovc2CFernandes5 misc2Nived_Nambiar5 Usernametwice232rzaneti5 eetuRobo2   Anil_g2   SharonS2  

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (1,134)