I think this will require multiple JSON expressions and Y/N conditions (for null) to allow for the flexibility of all the files I may need uploaded. I just am unfamiliar with how to build it.
Here is the general flow I am trying to achieve:
1. User submits an MS Form that has five sections and "branching" built-in to guide the user through the submission. Here is a snip of the beginning of the Form (total of 128x Questions, 8x of which allow the user to upload multiple files that are required depending on their responses.
2. The user might be required to upload multiple documents across 1-5x different questions, depending on their inputs.
3. I want these attachments to automate into a SharePoint List and simultaneously attached to an automated email.
I have been successful in getting up to 2x files uploaded into the SharePoint list and 1x file uploaded as an attachment in an email.
Here is the Problem I am trying to solve:
1) I am unclear how to build the flow to have more than 2x files across multiple MS Form questions and account for "null" answers. Here is the flow from MS Forms to my SharePoint List.
2) I am unclear how to build the email flow to have more than 1x file attached from the MS Form submission. Here is my flow from MS Forms to Email.
Solved! Go to Solution.
@pbj2011 As suggested in my original post you should be testing your flow at each stage and troubleshoot at each stage before trying to build the full flow and troubleshoot later.
If you copy the File Path from the failed Get file content using path action and paste it into your browser. Does the file come up? If it does, it means that you might need to either add a delay before this action to ensure the file is fully uploaded before you try to run it—you could also add a delay at the start of the flow to ensure all files are uploaded before the rest of the actions in your flow run.
Alternatively you could add a Do Until loop.
You can also manually check your Document library to see if the file is there as well.
You've set up the condition check incorrectly. The value entered into the second value field should be zero not null.
In this particular flow run I purposely didn't upload any files. The output of the Compose action is zero.
When the condition check is run and the value in the second field is zero, it'll return false. This means there aren't any items returned.
However, if you insert the second value as null, it'll return true—which is "correct" but not the result you want. If there are zero files returned—you want the result to be false so that nothing happens. Or, if you do want actions to be taken if the result is false you need to add additional conditions to the NO branch.
The reason your attachments aren't being collected is that the JSON is formatted incorrectly. The JSON is case sensitive.
Name must have a capital N. ContentBytes must have a capital C and B.
Hope this helps!
If I helped you solve your problem—please mark my post as a solution ✅. Consider giving me a 👍 if you liked my response! |
@pbj2011 The logic of your flow needs a little adjusting. What you'll need to do is the following:
I'm only going to cover how to get the file uploads from your MS Form into SharePoint and attached to an email. If you need additional help on formatting your email or MS form responses— refer to this YT Tutorial I recently uploaded: How to Get a Microsoft Form RSVP Response into a SharePoint List
I cover the following in this video tutorial:
✅ How to get a Microsoft Form Response into SharePoint
✅ How to get a Microsoft Form ID
✅ How to get a Microsoft Form response
✅ How to Build a Microsoft Form with Conditional Fields
✅ How to used Branching in Microsoft Forms
✅ How to format Microsoft Form multiple choice responses for a SharePoint multi-choice column
✅ How to parse a Microsoft Form multiple choice response as string of text
✅ How to convert a text response to a number
✅ How to use the Switch action
✅ How to create a custom email confirmation for a Microsoft Form submission
✅ How to Create a Custom View in a SharePoint list
✅ How to use the Compose Action
✅ How to write Power Automate Expressions
In the tutorial I cover how to use a manual trigger so that you don't need to submit a form each time to trigger your flow. Please reference this section of the tutorial on how to do this.
I'm using a Scope action to group the next few actions in the flow. Scope actions are great because they help keep my flow organized. I can also quickly collapse multiple actions with a single click. The Scope action is optional.
Add a Compose action for each File Upload field in your form. For my demo I have 3 file upload fields.
Insert the json() expression. This function will convert the file upload details into a readable format—a JSON array.
Click on the Dynamic content tab and insert the appropriate MS Form output.
Repeat this step for each of the file upload fields in your form. Tip: Remember to rename your actions to keep your flow organized.
Next you'll need to combine the file upload JSON arrays into a single array. Add a Compose action. I've nested mine inside another Scope action (the Scope action is optional).
To combine arrays into a single array. You'll need an expression. First you'll need an expression to check if the array is empty. If it is, you'll need to output an empty array instead of a null value. You'll be using the union() function to combine the arrays and this function requires arrays. If you try to pass a null value you'll get an error.
To check if the array is empty, we'll need to use the empty() function.
Click on the Dynamic content tab and insert the output from the Compose action that is storing the response from the first file upload field. Note: This is why it's important to rename your actions. Otherwise things can get confusing really fast.
Next, we'll need to use the if() function.The if() function takes three parameters. The first parameter is a condition that returns a boolan value (aka true or false), the second parameter is the value that is returned if the condition is true. The last parameter is the value returned if the condition is false.
Go to the start of the expression by pressing the up arrow key and type in if with an opening parenthesis. Keep an eye out for the expression tooltip. It'll bold the text of the parameter you are currently setting.
Go to the end of the expression by pressing the down arrow key and enter a comma and insert:
json('[]')
This is the true value. In other words, if your array from the first file upload field is empty, it'll output an empty json array.
Add another comma and insert the output from the first file upload field again.
Add a closing parenthesis.
Your expression should look like this:
if(empty(outputs('Compose_-_Upload_Files_1')),json('[]'),outputs('Compose_-_Upload_Files_1'))
Keep in mind, if you've named your Compose actions differently than what i have in my flow, your expression will look slightly different.
Run a test. If your first file upload field does contain file uploads, you should see the details of those files in the outputs.
If your field doesn't contain any file uploads the Compose action will look like this:
If you click on the Click to download link—you'll see an empty array. This is what you want.
Because you have many file upload fields. It'll be a lot easier to compose your expression in a text editor. The expression editor in Power Automate makes it really hard to see the full expression.
Click on the expression label to open it up in the Expression field.
Copy the entire expression to your clipboard.
Paste it into a text editor. Add a comma at the end of the line.
Paste in as many lines as you need, ensuring that you add a comma after each line (except for the last line). In my case, I only have three file upload fields. You'll need to adjust the numbers for each line—this will only work if your Compose actions have the same syntax.
Next, wrap the entire expression in the union() function. The union() function will combine two or more arrays or collections into one and remove any duplicates in the process. In your scenario you don't need to worry about any duplicates as you are really using this function just to combine the arrays.
Copy this entire expression to your clipboard. Replace the existing expression with your new expression.
Use an expression to return the count of items from the Compose action above. This is can be helpful to troubleshoot.
Insert a Compose action. Add an Expression. Use the length() function.
Select the Dynamic content tab and insert the value dynamic content from the Get Items action into the length() function.
Run a test. Confirm the number in the Compose action output.
Add a Create Item action and insert any dynamic content where necessary.
Add an initialize variable action to your flow. Select Array as the type.
Add a Condition action to your flow. In the first value field, insert the output from the Compose action that is storing the count of files.
Change the operator to is not equal to and enter zero into the second value field.
In the YES branch add the rest of your actions.
Add an Apply to Each action into the YES branch. Insert the output from the Compose action with the array of files.
Add a Get file content using path action. You'll need this action to get each attachment's file content so that you can attach it the file to a SP item as well as an email.
In the File Path field, you'll need to use an expression to access the file path.
If you take a look at the output of the Compose action that combines the file arrays, you'll see the dynamic content. The expression we'll be using is the item() function. To access the dynamic content you'll need the dynamic content key. The dynamic content key is the text in red between the double quotes.
In this case, it's link.
Insert an expression:
item()?['link']
Because you'll need the attachment name in the next couple actions, I'd recommend using a Compose action to store it. You'll use the same expression as above, you just need to adjust the dynamic content key from link to name.
Add an Add attachment action to your flow. Ensure it's nested inside the Apply to Each action.
For the ID, you'll need to insert the ID from the Create Item action.
For the File Name, you can insert the output from the Compose action above.
For the File Content, insert the File Content dynamic content from the Get file content using path action.
Run a test. Check to see if your SP item has been created with attachments.
Add an Append to Array Variable action. Insert the following JSON.
{
"Name": [Insert Compose Action Output],
"ContentBytes": [Insert File Content]
}
Add a Send an Email (V2) action outside of the Apply to each action.
Click on Show advanced options. Click on the icon to switch to input entire array.
Insert the variable into the Attachments field.
Run a test. Ensure that the email has all of your attachments.
Hope this helps!
If I helped you solve your problem—please mark my post as a solution ✅. Consider giving me a 👍 if you liked my response! |
If you are looking for a way to send multiple SharePoint List items that have been assigned to a user in an email—check out this YT Tutorial: How to Send a SINGLE EMAIL ✉️ with multiple SharePoint list items | Build THIS Power Automate Flow
In this tutorial I cover:
✅ How to send multiple list items in a single email with a Power Automate Flow
✅ How to create a dynamic date range
✅ How to use the Convert Time Zone action
✅ How to use a Filter Query in the Get Items action
✅ How to count number of items in an array
✅ How to use the Select action to extract a users display name and email address
✅ How to create a unique list of email addresses
✅ How to use the Create HTML Table action
✅ How to customize the HTML Table with CSS styles
✅ How to use the Send an email (V2) action
✅ How to use the Append to String Variable action
✅ How to create a custom list of items for an email
✅ How to use the Send an email (V2) action
✅ How to display singular or plural text based on the number of items returned
wow, extremely detailed. I'll build it out and let you know if I am able to get it to work, thanks!
I ran this entire flow. Here are the things that are not working with specifics below:
1. unable to find one of the three documents I attached in the MS Form.
2. did not attach the form to the email.
3. if a submission is received with no attachments, no email is sent.
Here is an overview of my flow and the error message I received:
ISSUE #1: unable to find one of the three documents I attached in the MS Form.
Error Message: "File not found clientRequestId: 0be37820-564f-41ac-919f-060a6d1af78f service RequestId: 0be37820-564f-41ac-919f-060a6d1af78f
Below is the precise structure of my flow:
Condition
Section 1 = 'Compose_-_Count_of_Files'
Apply to Each
Outputs = 'Compose_-_Combine_Uploaded_Files'
Get file content using path
File Path ='item()?['link']'
Compose - Attachment Name
Inputs = 'item()?['name']'
Add Attachment
File Name = "Compose_-_Attachment_Name'
I uploaded 3x files into this submission, only two attached successfully to the SP List. This meant that 5x files were "null" value. It seams like the flow ran correctly, but failed to find that 3rd attachment.
All other content was input into SP correctly without any issues. It was just that one attachment that I think failed to upload. But I could be wrong, still learning how to read PA.
ISSUE #2. did not attach the form to the email.
ISSUE #3. if a submission is received with no attachments, no email is sent.
I think this is a relatively easy fix. There are some instances where there will not zero attachments in a form submission. I think this means that I just need to mirror the "If yes" actions under the "If no" portion...unless this will send duplicate emails?
@pbj2011 As suggested in my original post you should be testing your flow at each stage and troubleshoot at each stage before trying to build the full flow and troubleshoot later.
If you copy the File Path from the failed Get file content using path action and paste it into your browser. Does the file come up? If it does, it means that you might need to either add a delay before this action to ensure the file is fully uploaded before you try to run it—you could also add a delay at the start of the flow to ensure all files are uploaded before the rest of the actions in your flow run.
Alternatively you could add a Do Until loop.
You can also manually check your Document library to see if the file is there as well.
You've set up the condition check incorrectly. The value entered into the second value field should be zero not null.
In this particular flow run I purposely didn't upload any files. The output of the Compose action is zero.
When the condition check is run and the value in the second field is zero, it'll return false. This means there aren't any items returned.
However, if you insert the second value as null, it'll return true—which is "correct" but not the result you want. If there are zero files returned—you want the result to be false so that nothing happens. Or, if you do want actions to be taken if the result is false you need to add additional conditions to the NO branch.
The reason your attachments aren't being collected is that the JSON is formatted incorrectly. The JSON is case sensitive.
Name must have a capital N. ContentBytes must have a capital C and B.
Hope this helps!
If I helped you solve your problem—please mark my post as a solution ✅. Consider giving me a 👍 if you liked my response! |
Apologies for the hijack, but keen to tease out a similar problem. I have the same workflow effectively, except I am working with 13 file arrays. I understand that union can only combine 10 maximum parameters.
So, how can i combine all 13 into a single array to attach to my email?
Value your input!
@Codatron It would be helpful to see a screenshot of your full flow. The union() function only accepts two parameters. It can only combine one array with another.
I'd also recommend starting a new post since this one has already been marked as solved.
Thanks @creativeopinion
Not surprisingly - in the act of typing out my problem as a new questions I saw my error in the union code and solved my issue!
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!
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
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.
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