cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
CindyZ
Post Prodigy
Post Prodigy

Order of Archive; Filtering an Array; Failing on Compose Action

I have a SHAREPOINT list of events I have filtered to archive by a particular date. 

I also have related documents in document library.  The EventID in the Document library matches to the ID of the list items.  Not all list items to be archived will have related documents and some items will have multiple documents.  After the documents are moved to the archive document library and the list item is archived, then I will delete the list item.

My GetItems filters my list items perfectly. 

Since I already have the ID from the filtered GetIems, I'd like to refer to that array of records when I check to see if there are matches to the ID for any related documents in the document library.

I have a few of questions.

 

  1. Can I perform the copy and delete for the list item as well as documents moves in parallel or should I archive the list first and then move the documents and then delete the list item? 

 

In an attempt to accomplish what I need and ensure this is working correctly, I've inserted a Select and a Compose after my GFPO-GetFilePropertiesOnly which I'd hoped would filter my Get Items to find related documents in the document library and then show me the count of the filtered items.

However, the SelectItemsWithDocs is pulling all records (even if no related documents exist) and ComposeItemsWithDocs is not returning a count.   The SelectItemsWithDocs is, in fact, pulling the properties of the matching documents when they exist.

 

  1. Can someone tell me what I need to do so the Select pulls only the file properties of the documents needed instead of all properties for all list items.
  2. What do I need to do to get compose to correctly calculate how records have documents to be moved and/or the total documents to be moved?
     

Note: this is failing at the point of Compose/CountItemsWithDocs with this message:

"Unable to process template language expressions in action 'Compose_2' inputs at line '0' and column '0': 'The template language expression 'length(outputs('GFPO-GetFilePropertiesOnly')?['body']['Select'])' cannot be evaluated because property 'Select' doesn't exist, available properties are 'value'. Please see https://aka.ms/logicexpressions for usage details.'"

 

CindyZ_2-1712712006257.png

 

Thanks for your consideration in helping me out with this.  

 

Cindy

 

4 REPLIES 4

@CindyZ It's not ideal to use a Get File (Properties Only) action in an Apply to Each action. You'll want to use a Filter Array action instead.

 

A Get Items/Get Files (Properties Only)/Get Events—basically any action that returns multiple items should always be outside of the Apply to Each loop. This way you only retrieve the items ONCE. A Filter Array action should be used to filter out those items that have already been returned.

 

I would recommend you create a new flow and start fresh. Remember to rename your actions to keep your flow organized and test often at the end of each section so you can understand what's going on in your flow. 

Get Items

It sounds like you are already filtering out your list using a Filter Query which is great.

creativeopinion_0-1712716083132.png

I'm not sure if the Select action you have after the Get Items action in your original flow is necessary. Doesn't look like it (unless I'm missing something)

Return Count of Items

 

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.

creativeopinion_1-1712716181370.png

 

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

creativeopinion_2-1712716194182.png

 

Run a test. Review the outputs and ensure the Compose action is displaying the correct number of items you are expecting.

Get Files (Properties Only)

Add a Get files (properties only) action to the root of your flow. Fun fact. The Get Files (properties only) returns folders as well. You need to use a Filter Query to return Files only. Refer to this YT Short. If there are any other custom columns you can filter your files on (besides the EventID) you can add to your filter query. 

 

creativeopinion_4-1712716320271.png

 

Loop through Each SP Item

Add an Apply to Each action to your flow. Ensure you are selecting the proper dynamic content. You want to loop through each SP list item, select the value dynamic content from that action. 

creativeopinion_5-1712716425158.png

 

Filter Files

Insert a Filter Array action into the Apply to Each action. In the From field, insert the value dynamic content from the Get files (properties only) action. You want to use this action to filter the files returned by the Event ID column. 

 

From your original flow—it looks like you are comparing the value from the Event ID column to the SP ID column. 

creativeopinion_7-1712716564416.png

In the first value field select the dynamic content from the Get Files (properties only) action for the column in your document library that is storing the EventID (in my example, my column name is CustomID). Ensure you are selecting the correct dynamic content. 

 

Leave the operator as is equal to. In the second value field insert the ID dynamic content from the Get Items action. 

creativeopinion_8-1712716812233.png

It's important to note that the ID dynamic content from the Get Items action is an integer. If your Event ID is storing a string of text, you'll need to convert that to an integer using the int() function.

Return a Count of Filtered Files

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_9-1712716852626.png

 

Select the Dynamic content tab and insert the body dynamic content from the Filter Array action into the length() function.

creativeopinion_10-1712716867381.png

Run a test. Review the outputs. 

 

You might want to refer to to these two YT Tutorials:

 

Are you using the Microsoft Power Automate Filter Array Action wrong?

In this video tutorial I’ll show you 3 practical ways to use the Filter Array action and how to use it properly.

 

1️⃣ Cross-Referencing Data

2️⃣ Filtering by Key

3️⃣ Substring Matching

 

Did you know that the Condition action has a limit of 10 conditions? Although it might look like the Filter Array action can only accept one condition—this is not true. By using the advanced mode you can enter multiple conditions into a Filter Array action with an expression.

 

IN THIS VIDEO:

 3 Ways to Use the Filter Array Action

 How to use the Scope Action to Group Actions

 How to Check the Number of Items returned from a Filter Array Action

 How to Cross-Reference Data in Excel with a SharePoint List

 How the Filter Array Action Works

 How to Access the Dynamic Content from a Filter Array Action

 How to Filter Items by a Key

 How to Filter Items by Matching a Substring

 How to Use Multiple Conditions in a Filter Array Action

 

---

 

3 Mistakes YOU 🫵 are Making with the Apply to Each Action in your Microsoft Power Automate Flow

 

In this video tutorial I’ll go over how to avoid these common mistakes when using the Apply to Each action in a Power Automate flow:

 

1️⃣ Looping through a Single Item

2️⃣ Creating Unnecessary Nested Loops

3️⃣ Looping through an Unfiltered Array

 

At the end of the video I share a few helpful insights when it comes to using the Apply to Each action in your flow.

 

IN THIS VIDEO:

 How to avoid the Apply to Each action with a single item array

 How to use the item() function to access dynamic content in an array

 How to prevent unnecessary nested Apply to Each action loops

 How to use the Select action

 How to convert an array to a string with the Select action

How to use the Filter Query field

 How to count the number of items in an array

 How to use a condition control

 How to use the concurrency control

 How to set a top count

 How to use Compose actions for troubleshooting

 

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!

👉 Level up your Power Automate skills by checking out my tutorials on YouTube
👉 Tips and Tricks on TikTok and Instagram

 

CindyZ
Post Prodigy
Post Prodigy

@Thanks so much for this thorough response.  I'll be working on this today and let you know the outcome. 

 

CindyZ
Post Prodigy
Post Prodigy

I'm really sorry that I'm still having trouble because I believe your instructions are perfectly clear so I'm not sure where I'm misunderstanding.    Below is what I currently have. 

 

I tried a number of runs. I tried to run it without the integer correction.  That ran beautifully but did not return any records. 

I did not start over as you suggested simply because my flow works fine up until the point of where I Get Files (Properties  only).  Also, yes, you are correct re the Select but I wanted to actually see what records were being pulled since I had so many.  I can delete that once I'm comfortable. 

If found that at the point where you said "leave the operator as is equal to. In the second value field insert the ID dynamic content from the Get Items action that even if I selected the ID from the GetItemsEventsListthat it would always revert to the ApplyToEachFromGetItemsEventsList.  It would also run fine except it still showed me all four hundred records.  It did not filter out only those records where the ID's matched and it did not pull any document references -- I was getting that yesterday. 

So, I finally forced the "GetItemsEventsList" into the field after "is equal to" and this is the result.  

I'm anxious to find out where I've gone wrong; especially since I've tried this multiple times in multiple ways.  

Thanks again for all your help.  I'd just found your videos yesterdays and fully watched the short as well as the other recommended ones today.  I look forward to working my way through all the others.  Your teaching is crystal clear.  


CindyZ_0-1712789393976.png

 



@CindyZ The dynamic content you have inserted into the second value field is incorrect. You also need to swap the dynamic content. 

creativeopinion_1-1712791162143.png

 

Take a look at the Apply to Each action, you are looping through each SP Item.

creativeopinion_2-1712791187857.png

The purpose of the Filter Array action is to filter out the file(s) that have the Event ID that matches the current SP Item's ID (or whatever unique ID you are using to search) that you are looping through. 

 

For that reason, the value inserted into the Filter Array action should be taken from the Get files (properties only) action—which you have.

 

Ensure that, the dynamic content entered in the first field, is the dynamic content of the column from your document library. In my case, it's Custom ID. Because my Custom ID column is a number column (I don't require the int() function).

creativeopinion_3-1712791302098.png

creativeopinion_4-1712791385851.png

Leave the operator as equal to since you are looking for a match. 

 

creativeopinion_5-1712791406338.png

In the second value field you want to insert the dynamic content of whatever column in your SP list has the value you are matching to your document library. In my case, I'm just using the default SP ID column. Select the appropriate dynamic content in your flow. 

creativeopinion_6-1712791506492.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!

👉 Level up your Power Automate skills by checking out my tutorials on YouTube
👉 Tips and Tricks on TikTok and Instagram

 

 

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