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

Getting List Items that have three column fields in common, and updating those groups

Please forgive the mess that is my flow.  I quit in the middle of the build when I realized it was beyond my capabilities. 

I have a SharePoint list that houses customer order details.  It's important to note that I must group records by PONumber, PartNumber, and DueDate, as that accounts for every data circumstance.  Meaning, that our customers may put multiple part numbers on a single PO, but with different due dates.  To segregate the manufacturing steps, I have to group items this way.

Krickner_0-1702599301267.png


What I'm trying to accomplish:

I need to create a flow that fires off every Saturday and gets my list items, groups all items that have matching "PONumber", "PartNumber", and "DueDate".  With those items grouped, I need the flow to check the "StepStatus" field in each grouped item, and if the entire group has a "StepStatus" of "Complete" I need to update the "OrderStatus" to "Closed" on each group item.

I will paste my best shot at this, and it was a long shot.  Any guidance would be very much appreciated.


Krickner_2-1702599911953.png

Krickner_3-1702600014353.png

Krickner_5-1702600061127.png

Krickner_6-1702600506308.png

The append to array variable:
{
"ItemID": @{items('Apply_to_each')?['ID']},
"PONumber": @{variables('CurrentPONumber')},
"PartNumber": @{variables('CurrentPartNumber')},
"DueDate": @{variables('CurrentDueDate')}
}

The append to array variable 2:
{
"ItemID": @{items('Apply_to_each')?['ID']},
"PONumber": @{variables('CurrentPONumber')},
"PartNumber": @{variables('CurrentPartNumber')},
"DueDate": @{variables('CurrentDueDate')},
"IsNewGroup": true
}

Krickner_7-1702600862871.png

Append to array variable 3
{
"PONumber": @{items('Apply_to_each_3')?['PONumber']},
"PartNumber": @{items('Apply_to_each_3')?['PartNumber']},
"DueDate": @{items('Apply_to_each_3')?['DueDate']},
"Items": [
@{items('Apply_to_each_3')}
]
}

 

Krickner_8-1702601086913.png

Krickner_10-1702601121363.png

 

 

 

 





1 ACCEPTED SOLUTION

Accepted Solutions

@Krickner You definitely don't need to use Arrays. I think you can accomplish this with a more streamlined flow.

 

Concepts covered can be reviewed in a few YT Tutorials I have up:

Get Items from List

Depending on how many items you have in your SP List, I would recommend limiting the Top Count to a smaller number than the total number of items in your list. This will increase the speed of your flow runs. Instead of returning all items in your list—it'll limit the Get Items action to the number entered here.

 

creativeopinion_0-1702610633425.png

 

Get PO Number Groups

Because you want to "group" your items by PO number, you'll need to create an array of unique PO numbers. Tip: Remember to rename your actions as you go to keep things organized!

 

Add a Select action to your flow. Press the icon to switch from key value to map mode.

creativeopinion_2-1702610766795.png

Insert the PO number dynamic content. For my SP list I'm storing the order number in the Title column.

creativeopinion_3-1702610787832.png

Run a test. The Select action will return all the order numbers from your SP list. However, there are duplicate values that you will need to remove.

creativeopinion_4-1702610982309.png

 

Remove Duplicate Values from Array

To create an array of unique values you'll need to use an expression and the union() function. You can reference this YT Short to see a demo of this.

 

Add a Compose action to your flow and insert an expression. Use the union() function. The union() function takes two parameters—two arrays you'd like to combine. The neat thing about this function is if there are duplicate items—it'll remove them!

creativeopinion_5-1702611179340.png

Select the dynamic content tab and insert the output from the Select action above.

creativeopinion_6-1702611250906.png

Add a comma and insert the same output. This expression will combine the output from the select action and get rid of any duplicates. 

creativeopinion_7-1702611281680.png

Run a test. Review the output from the Compose action. You should be left with a unique list of order numbers.

creativeopinion_8-1702611321520.png

Use Scope Actions to Group Actions (optional)

This is optional. I like to use Scope actions to group my actions together. It keeps things organized and also makes it easy to collapse multiple actions with a single click.

creativeopinion_9-1702611407352.png

 

Apply to Each Order

Add an Apply to Each action to your flow. You'll use this to loop through each order. Ensure that you are inserting the outputs from the Compose action—not the select action. Remember that the compose action contains unique orders.

creativeopinion_10-1702611453957.png

Add a Compose action to store the current item being looped through. This is optional—however I find that this can help with troubleshooting.

creativeopinion_11-1702611563195.png

Get All Items for Order

Next, add a Filter Array action. Use this action to get all the items for the current order.

 

In the From field, insert the value dynamic content from the Get Items action. In the first value field—insert the PO number dynamic content from the Get Items action (my order number is stored in the Title column). 

 

Leave the operator as is equal to. In the second value field insert the output from the Compose action above.

creativeopinion_26-1702612838499.png

 

Whenever I use a Filter Array 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.

creativeopinion_27-1702612871150.png

 

 

Select the Dynamic content tab and insert the value dynamic content from the Get Items action into the length() function.

creativeopinion_28-1702612889458.png

 

 

Run a test. Review the outputs. Compare the outputs against your SP list (keep in mind if you've limited the count... the items returned may not be accurate)

creativeopinion_29-1702612924488.png

 

Filter the Filtered Array

Add another Filter Array action. In the From field, insert the Body from the Filter Array action above. You are going to filter out items with a status of complete. You'll then compare the length of the second filter array to the first to see if all items should be marked closed.

 

creativeopinion_31-1702613344869.png

Refer to this section of a YT Tutorial I uploaded on how to get dynamic content from a Filter Array action. Take a look at the outputs from the first Filter Array action. You'll need to compose an expression to return the dynamic content from a Filter Array action. The dynamic content key is the text in red between the double quotes.

creativeopinion_32-1702613468911.png

Use the item() expression, add a question mark and square brackets between single quotes.

item()?['']

 

In between the single quotes, enter in the dynamic content key. Since the Step Status column is a choice field you need to add a forward slash between StepStatus and Value. Note: You'll need to verify the output of YOUR Filter Array action as the key may be different. Please note that the keys are case sensitive.

creativeopinion_36-1702613801594.png

 

creativeopinion_34-1702613531625.png

Add a Compose action to store the count of items from the Filter Array action. Use the length() function as you did previously.

creativeopinion_35-1702613659229.png

Run a test. Review the outputs. 

 

This is an example where all items in the order are marked complete as the output from the first Filter Array action matches the output from the second Filter Array action. 

creativeopinion_37-1702613931217.png

 

This is an example where the outputs do not match.

creativeopinion_38-1702614002151.png

Again, this is optional but I've grouped the last four actions into a Scope action.

creativeopinion_39-1702614098007.png

 

Condition

Add a Condition action. You'll only want to continue on with the flow if the two Compose action outputs match. Otherwise nothing needs to happen.

 

This is why it's important to name your actions properly—otherwise you won't know which output belongs to which action.

 

In the first value field insert the output from one of the two compose actions that are storing the count from the Filter Array actions. In the second value field, insert the other compose action that is storing the count from the other Filter Array action. 

 

This Condition action will compare the outputs to see if they match.

creativeopinion_40-1702614179055.png

Place the rest of your actions into the YES branch. If you do want something to happen when the numbers don't match, add those actions to the NO branch.

 

Apply to Each Order Item

Add an Apply to Each action. You can actually insert either of the body dynamic content from either of the Filter Array action—since the flow will only continue if all items need to be marked as Closed (aka they meet your criteria).

creativeopinion_41-1702614379358.png

 

Add a Compose action. This is optional as you can insert the expression directly into the Update Item action. However, I prefer to use Compose actions.

 

Insert the item() function. 

creativeopinion_42-1702614520657.png

The dynamic content key for the ID is ID.

creativeopinion_43-1702614545790.png

Run a test if you'd like to confirm the ID's of the items that will be marked as closed. 

 

Update Item

Add an Update Item action to your flow. In the ID field, insert the output from the Compose action storing the ID—or insert the expression directly into this field. Select the Closed order status.

creativeopinion_44-1702614641091.png

Concurrency Control

Since you aren't using any variables in the flow you can turn on the concurrency control which can reduce the time it takes your flow to run. You'll have to turn it on for both Apply to Each actions. This will run multiple instances of the Apply to Each action simultaneously.  

creativeopinion_46-1702614850560.png

 

creativeopinion_47-1702614867230.png

 

creativeopinion_48-1702614992615.png

 

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!

👉 Watch my tutorials on YouTube
👉 Tips and Tricks on TikTok

View solution in original post

5 REPLIES 5

@Krickner You definitely don't need to use Arrays. I think you can accomplish this with a more streamlined flow.

 

Concepts covered can be reviewed in a few YT Tutorials I have up:

Get Items from List

Depending on how many items you have in your SP List, I would recommend limiting the Top Count to a smaller number than the total number of items in your list. This will increase the speed of your flow runs. Instead of returning all items in your list—it'll limit the Get Items action to the number entered here.

 

creativeopinion_0-1702610633425.png

 

Get PO Number Groups

Because you want to "group" your items by PO number, you'll need to create an array of unique PO numbers. Tip: Remember to rename your actions as you go to keep things organized!

 

Add a Select action to your flow. Press the icon to switch from key value to map mode.

creativeopinion_2-1702610766795.png

Insert the PO number dynamic content. For my SP list I'm storing the order number in the Title column.

creativeopinion_3-1702610787832.png

Run a test. The Select action will return all the order numbers from your SP list. However, there are duplicate values that you will need to remove.

creativeopinion_4-1702610982309.png

 

Remove Duplicate Values from Array

To create an array of unique values you'll need to use an expression and the union() function. You can reference this YT Short to see a demo of this.

 

Add a Compose action to your flow and insert an expression. Use the union() function. The union() function takes two parameters—two arrays you'd like to combine. The neat thing about this function is if there are duplicate items—it'll remove them!

creativeopinion_5-1702611179340.png

Select the dynamic content tab and insert the output from the Select action above.

creativeopinion_6-1702611250906.png

Add a comma and insert the same output. This expression will combine the output from the select action and get rid of any duplicates. 

creativeopinion_7-1702611281680.png

Run a test. Review the output from the Compose action. You should be left with a unique list of order numbers.

creativeopinion_8-1702611321520.png

Use Scope Actions to Group Actions (optional)

This is optional. I like to use Scope actions to group my actions together. It keeps things organized and also makes it easy to collapse multiple actions with a single click.

creativeopinion_9-1702611407352.png

 

Apply to Each Order

Add an Apply to Each action to your flow. You'll use this to loop through each order. Ensure that you are inserting the outputs from the Compose action—not the select action. Remember that the compose action contains unique orders.

creativeopinion_10-1702611453957.png

Add a Compose action to store the current item being looped through. This is optional—however I find that this can help with troubleshooting.

creativeopinion_11-1702611563195.png

Get All Items for Order

Next, add a Filter Array action. Use this action to get all the items for the current order.

 

In the From field, insert the value dynamic content from the Get Items action. In the first value field—insert the PO number dynamic content from the Get Items action (my order number is stored in the Title column). 

 

Leave the operator as is equal to. In the second value field insert the output from the Compose action above.

creativeopinion_26-1702612838499.png

 

Whenever I use a Filter Array 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.

creativeopinion_27-1702612871150.png

 

 

Select the Dynamic content tab and insert the value dynamic content from the Get Items action into the length() function.

creativeopinion_28-1702612889458.png

 

 

Run a test. Review the outputs. Compare the outputs against your SP list (keep in mind if you've limited the count... the items returned may not be accurate)

creativeopinion_29-1702612924488.png

 

Filter the Filtered Array

Add another Filter Array action. In the From field, insert the Body from the Filter Array action above. You are going to filter out items with a status of complete. You'll then compare the length of the second filter array to the first to see if all items should be marked closed.

 

creativeopinion_31-1702613344869.png

Refer to this section of a YT Tutorial I uploaded on how to get dynamic content from a Filter Array action. Take a look at the outputs from the first Filter Array action. You'll need to compose an expression to return the dynamic content from a Filter Array action. The dynamic content key is the text in red between the double quotes.

creativeopinion_32-1702613468911.png

Use the item() expression, add a question mark and square brackets between single quotes.

item()?['']

 

In between the single quotes, enter in the dynamic content key. Since the Step Status column is a choice field you need to add a forward slash between StepStatus and Value. Note: You'll need to verify the output of YOUR Filter Array action as the key may be different. Please note that the keys are case sensitive.

creativeopinion_36-1702613801594.png

 

creativeopinion_34-1702613531625.png

Add a Compose action to store the count of items from the Filter Array action. Use the length() function as you did previously.

creativeopinion_35-1702613659229.png

Run a test. Review the outputs. 

 

This is an example where all items in the order are marked complete as the output from the first Filter Array action matches the output from the second Filter Array action. 

creativeopinion_37-1702613931217.png

 

This is an example where the outputs do not match.

creativeopinion_38-1702614002151.png

Again, this is optional but I've grouped the last four actions into a Scope action.

creativeopinion_39-1702614098007.png

 

Condition

Add a Condition action. You'll only want to continue on with the flow if the two Compose action outputs match. Otherwise nothing needs to happen.

 

This is why it's important to name your actions properly—otherwise you won't know which output belongs to which action.

 

In the first value field insert the output from one of the two compose actions that are storing the count from the Filter Array actions. In the second value field, insert the other compose action that is storing the count from the other Filter Array action. 

 

This Condition action will compare the outputs to see if they match.

creativeopinion_40-1702614179055.png

Place the rest of your actions into the YES branch. If you do want something to happen when the numbers don't match, add those actions to the NO branch.

 

Apply to Each Order Item

Add an Apply to Each action. You can actually insert either of the body dynamic content from either of the Filter Array action—since the flow will only continue if all items need to be marked as Closed (aka they meet your criteria).

creativeopinion_41-1702614379358.png

 

Add a Compose action. This is optional as you can insert the expression directly into the Update Item action. However, I prefer to use Compose actions.

 

Insert the item() function. 

creativeopinion_42-1702614520657.png

The dynamic content key for the ID is ID.

creativeopinion_43-1702614545790.png

Run a test if you'd like to confirm the ID's of the items that will be marked as closed. 

 

Update Item

Add an Update Item action to your flow. In the ID field, insert the output from the Compose action storing the ID—or insert the expression directly into this field. Select the Closed order status.

creativeopinion_44-1702614641091.png

Concurrency Control

Since you aren't using any variables in the flow you can turn on the concurrency control which can reduce the time it takes your flow to run. You'll have to turn it on for both Apply to Each actions. This will run multiple instances of the Apply to Each action simultaneously.  

creativeopinion_46-1702614850560.png

 

creativeopinion_47-1702614867230.png

 

creativeopinion_48-1702614992615.png

 

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!

👉 Watch my tutorials on YouTube
👉 Tips and Tricks on TikTok

@creativeopinion everything up to the condition is working perfectly.  What's odd is I can see that the All Count is equal to the Complete count, so I'm uncertain why the condition isn't showing any values.  I want to give a sincere thank you for helping me with this.  I've posted the results I'm getting below:

Krickner_0-1702650391861.png

Krickner_1-1702650499679.png

 

 

 

@creativeopinion , please disregard.  I made an error in the setup of the condition.  It's working like a charm!!! I cannot thank you enough.  Not only have you solved a problem for me, I've learned quite a bit based on the way you process situations such as this.  I wish you the very best.

@creativeopinion enjoy the coffee. It's the least I can do ; )

@Krickner thanks so much! Appreciate it and I'm glad I could help. More importantly..glad I taught you something! 😄

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,455)