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

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
Highlighted
Community Support
Community Support

Re: Delete items in SP list after certain count returned

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
Highlighted
Community Support
Community Support

Re: Delete items in SP list after certain count returned

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

Highlighted
Helper III
Helper III

Re: Delete items in SP list after certain count returned

@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

Re: Delete items in SP list after certain count returned

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.

Highlighted
Helper III
Helper III

Re: Delete items in SP list after certain count returned

@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 🙂

Highlighted
Super User II
Super User II

Re: Delete items in SP list after certain count returned


@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
FirstImage

Microsoft Ignite 2020

Check out the announcement of Power Platform content at Microsoft Ignite!

thirdImage

Experience what's new for Power Automate

Join us for an in-depth look at the new Power Automate features and capabilities at the free Microsoft Business Applications Launch Event.

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (8,584)