I build a flow where every time a response submitted in Microsoft forms it will directly connect to Sharepoint calendar. So, in the form you need to input the dates that you will going to work in the office. I put 5 lines so if they need to work in the office for 5 days, they can just fill-up 1 form. But the thing is if they just fill-up 1 line and they will not fill up the other 4 because they will just report to the office for 1 day and this happens multiple times consecutively. There will be an error and my flow will turn off. I think the problem is on how I build my flow. Can you please help me how to fix it. I will attach the flow I create and the forms.
@Lablirows The parallel Apply to Each actions are unnecessary and inefficient.
While you are building your flow I would recommend you use a Manual trigger. This will help speed up your flow building process and allow you to quickly test at each stage of your flow. Tip: Always rename your actions to keep things organized!
Review a previous flow run and copy the Form Id to your clipboard and take note of the Response Id.
Insert that into the Get response details action of your flow.
Because you have multiple onsite details that you'd like to loop through. It's best to create an Array that can be looped through. For more tips on using the Apply to Each action—refer to this recent YT Tutorial I uploaded.
By creating an array you can use a Filter Array action to pull out the items that only contain values in the location and date fields. For more information on how to use the Filter Array action—refer to this YT Tutorial.
A basic array looks like this.
[
{
"item 1"
},
{
"item 2"
},
{
"item 3"
}
]
For your array, treat each onsite option as an item. The key (eg. "onsite", "location", "date" can be customized to your requirements. You'll just need to note these keys for use later.
The content (eg. Onsite 1, Onsite 2, Onsite 3) is what will be outputted when you reference the key in an expression. This can also be customized to your requirements.
[
{
"onsite": "Onsite 1",
"location": [insert dynamic content for location],
"date":[insert dynamic content for date]
},
{
"onsite": "Onsite 2",
"location": [insert dynamic content for location],
"date":[insert dynamic content for date]
},
{
"onsite": "Onsite 3",
"location": [insert dynamic content for location],
"date":[insert dynamic content for date]
}
]
Run a test. Any dynamic fields that are empty will display "". In this example below, the Onsite 2 and Onsite 3
Add a Filter Array action to your flow. You'll use this action to filter out items that do not have an empty location and empty date.
In the From field, insert the Outputs from the Compose action above (the one that has your array). Click on Edit in advance mode.
You'll need to use an expression. Do not try to type into this field. You will need to use a text editor to compose your expression first, then copy/paste it into the field. Refer to this section of my YT Tutorial on how to use multiple conditions in the Filter Array action and why you can't type into that field.
The expression you will need to use will look something like this. Note: This may be a bit different based on your array keys.
@and(not(equals(item()?['location'], '')), or(not(equals(item()?['date'], '')), equals(item()?['date'], '')))
Run a test. As you can see the inputs show 3 items in the array. However after the array has been filtered, only a single item has returned.
Whenever I use a Filter Query in a Get Items action, I always like to return the count of items returned in a Compose action. This is helpful when building a flow and can also be used to troubleshoot your flow.
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.
Add a Condition action to your flow to check the number of items returned. If no items have returned, do nothing, The rest of your actions can go into the YES branch.
Add an Apply to Each action and insert the Body outputs from the Filter Array action. This Apply to Each action will loop through each item from your array that has been filtered (aka the outputs from the Filter Array action).
For more information on how to access dynamic content from a Filter Array action—refer to this section of my YT Tutorial. The Compose actions are optional—however they can help with troubleshooting and it's easy to confirm the dynamic content before using it in a Create Item action.
Use the item() function. Insert the following into the Expression field.
item()?['']
In between the single quotes enter the dynamic content key. For this example, I'll use onsite.
Repeat these steps for each key.
Run a test. Verify the outputs of each Compose action.
You can now insert the Create Item action and use the outputs from each compose action in the appropriate fields.
Once you've tested your flow and confirmed everything works, create a copy of your flow and replace the trigger. I would recommend keeping the manually triggered flow for testing purposes. This will be handy should your form change in the future or if you are running to any issues with the automatically triggered flow.
Replace the response ID with the Response id dynamic content from the flow trigger.
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! |
WarrenBelz
146,651
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,999
Most Valuable Professional