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

Delete items in SP list after certain count returned

Hey all, 

 

I have two SP lists. One of those lists is a "back up list" where I have a flow that copies every item that gets entered into OG list.

In the OG list, I want to maintain a pretty low item count with flow. So I need to create a scheduled flow that runs every couple days, gets the item count from OG list, and if there are items over 350, it gets them, confirms that they are in the back up list, then deletes them. I have a Parent ID column in the Back up list that can be referenced.

 

I find this to be kind of a complicated flow concept for me. Can anyone help me construct this flow?

 

Thanks, 

 

-T

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support
Community Support

Hi @TorreyFalconer ,

 

Please refer to screenshot below to create the flow:

1.png2.png3.png

The expression in the Condition as below:

length(body('Get_items')?['value'])

The expression in the Condition 2 as below:

length(body('Filter_array'))

 

Best regards,

Alice       

 

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
Community Support
Community Support

Hi @TorreyFalconer ,

 

Please refer to screenshot below to create the flow:

1.png2.png3.png

The expression in the Condition as below:

length(body('Get_items')?['value'])

The expression in the Condition 2 as below:

length(body('Filter_array'))

 

Best regards,

Alice       

 

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

@v-alzhan-msft Holy! That's amazing. Thank you!

I do have one question though if that's ok- on both 'Get Items' and 'Get Items 2' it looks like you are asking for all items in the list. I haven't ran it yet, but it looks like after you have do the condition count, you 'Get Items 2' (all items) and then check to see if they are in the back up list. Is there a way to just get the most recent items that have been made after count 350? 

 

Second question- the "delete item" at the end, wouldn't that delete all items in the list if they exist in the other list? I realize it's strange, but I actually want to keep 350 items in List B, so only the items after 350 should be deleted....if that makes sense. 

 

I feel like I need to be filtering the "Get Items" and "Get Items-2"?

Community Support
Community Support

Hi @TorreyFalconer ,

 

If your original problem has been solved, please go ahead and mark the post as solved by clicking “Accept as Solution” so that this thread will be marked for other users to easily identify!

 

If you have other problems, please create a new post in the forum so it could be replied and get answered quickly.

 

Best regards,

Alice       

 

Community Support Team _ Alice Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-alzhan-msft 

I'm confused....I just asked you those questions because you haven't fully resolved it. Certainly very close but please refer to my above questions so that I can finish the flow as per my original question 🙂


@TorreyFalconer wrote:

@v-alzhan-msft Holy! That's amazing. Thank you!

I do have one question though if that's ok- on both 'Get Items' and 'Get Items 2' it looks like you are asking for all items in the list. I haven't ran it yet, but it looks like after you have do the condition count, you 'Get Items 2' (all items) and then check to see if they are in the back up list. Is there a way to just get the most recent items that have been made after count 350? 

 

Second question- the "delete item" at the end, wouldn't that delete all items in the list if they exist in the other list? I realize it's strange, but I actually want to keep 350 items in List B, so only the items after 350 should be deleted....if that makes sense. 

 

I feel like I need to be filtering the "Get Items" and "Get Items-2"?


That is up to you and your workload. The example that @v-alzhan-msft provided should be used as a starting point for your Flow. What you are seeking to accomplish can be done using what is shown in the example.

Without insights into your exact workload and dataset, we can't decide for you if and/or when you should be filtering data, because your data is unique to you and your environment.

You can filter further as needed  for each and every step of your flow using the OData filtering for lists and/or with Filter Arrays and expand upon the provided guidance for your workload. 

👨🏻‍💻 If this reply answers your question or solves your issue, please ACCEPT AS SOLUTION ☑️. If you find this reply helpful, please consider giving it a LIKE 👍.

Helpful resources

Announcements
Microsoft Ignite

Microsoft Ignite

Join digitally, March 2–4, 2021 to explore new tech that's ready to implement. Experience the keynote in mixed reality through AltspaceVR!

New Super Users

Meet the Power Automate Super Users!

Many congratulations to the Season 1 2021 Flownaut Crew!

Microsoft Ignite

Microsoft Power Platform: 2021 Release Wave 1 Plan

Power Platform release plan for the 2021 release wave 1 describes all new features releasing from April through September 2021.

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Users online (58,804)