cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
brett1
Frequent Visitor

Trouble with Top Count in Get Current Items in List

I am trying to create a flow that grabs a specific entry from my sharepoint list to prepopulate a new entry if a new entry has the same name of a previous one.

I watched a video that showed that if you want more options with your filtering, etc. Then use Get Items not Get Item action.

 

 

If there are multiple, I just want to grab the most recent one (max ID). The problem is it seems to be ignoring my Top Count set to 1. I tried to initialize a variable instead and it is still grabbing all items that have the same name, not just the max one. 

 

Does anybody have any idea of where I am going wrong?

Thank you!

 

flow pic.png

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Trouble with Top Count in Get Current Items in List

@brett1 

I am stumped...

Do you, by any chance, have Concurrency control for your loops turned on anywhere that might impact this part of your Flow?  This can sometime play havoc with your Flow especially if you are using variables.

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott

View solution in original post

9 REPLIES 9
Super User
Super User

Re: Trouble with Top Count in Get Current Items in List

@brett1 

Can you post a screen shot of the output of one of your runs that shows that more than 1 item is being returned?

I just created a Flow very similar to yours and it ran as expected.

 

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott
brett1
Frequent Visitor

Re: Trouble with Top Count in Get Current Items in List

Interesting.

My output has lots of columns and shows up in a json body (is there a way to change it into table view like the list is?) so it's hard to show the output but here's a snip showing that it applies my next step to both of the list items in the same name.

flow pic 2.png

Super User
Super User

Re: Trouble with Top Count in Get Current Items in List

@brett1 

an you post a screen shot of the length() expression in your condition?

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott
brett1
Frequent Visitor

Re: Trouble with Top Count in Get Current Items in List

The expression is : 

length(actionBody('Get_Current_Items_In_List')?['value'])
 
But I don't believe that is the issue since I see both items in the json, right?
Super User
Super User

Re: Trouble with Top Count in Get Current Items in List

@brett1 

Hmmmm.....

Just for fun, would you mind hard coding a 1 as the top count rather than using the variable?

 

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott
brett1
Frequent Visitor

Re: Trouble with Top Count in Get Current Items in List

@ScottShearer 

 

Sure. I still have the same problem. And the confusing thing is it shows that it is being picked up as Top Count is 1 but yet the length of that expression is 2.

flow pic 3.png

Do you have any different ways that you can think to accomplish the same task of: if there exists 1 or more items with the same name, grab the most recent item based on row ID #? This seemed like the easiest way to me, but maybe there is a different solution.

Super User
Super User

Re: Trouble with Top Count in Get Current Items in List

@brett1 

I am stumped...

Do you, by any chance, have Concurrency control for your loops turned on anywhere that might impact this part of your Flow?  This can sometime play havoc with your Flow especially if you are using variables.

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott

View solution in original post

brett1
Frequent Visitor

Re: Trouble with Top Count in Get Current Items in List

They concurrency controls are set to off. But it really seems that the problem occurs in the Get Items part. I may try to do a loop through my Get Items and grab the max ID somehow and then set that as a variable in a "Get Item" step afterwards.

 

That may be a way to try to overcome this weird problem. I will let you know if I come across a solution.

Thank you for your help!

brett1
Frequent Visitor

Re: Trouble with Top Count in Get Current Items in List

@ScottShearer 

 

It looks like I was able to accomplish this.

So steps now are:

  • Get Items
  • Apply each loop with if statement to loop through and grab max ID
  • Get Item (put max ID in)

I feel like it shouldn't be this hard, but glad to have it resolved.

Helpful resources

Announcements
firstImage

New Ranks and Rank Icons released on April 21!

The time has come: We are finally able to share more details on the brand-new ranks coming to the Power Automate Community!

firstImage

Now Live: Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Users online (7,032)