cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sudosaurus
Post Partisan
Post Partisan

For each Get item action with condition takes a long time to update

Hello,

 

I have a SharePoint list that I'm using as a helpdesk and have a workflow that sends comments from SharePoint to a requesters email address.

 

When the requester replies to the email, there is a workflow that checks the subject line and matches the reference in the subject line against a ticket number in the SharePoint list.

 

The problem I have is that during the For each part of the workflow, it is taking a long time to loop through all the items in the list before it finds the matching item.

 

Earlier today it took 10 mins and now it's taking 22 mins.

 

It's worth noting that during testing we had 800 test tickets and rather than creating a new list for go live, we simply added dummy tickets to take it up to 999 items and then deleted these and went live at ticket reference CXL-1000 where 1000 is the SharePoint item ID. Even though the test tickets were deleted and not "visually" seen, I understand the ID's still remain in the backend database tables in SPO and thinking its taking time to loop through those as well? Even though Get items shows 343 items to search through when the workflow is running.

 

Any ideas?

 

My workflow is as below:

 

sudosaurus_0-1622648835315.png

sudosaurus_1-1622648857345.png

sudosaurus_2-1622648897584.png

sudosaurus_3-1622648924421.png

sudosaurus_4-1622648992256.png

sudosaurus_5-1622649075315.png

 

6 REPLIES 6
DamoBird365
Super User
Super User

Hi @sudosaurus 

 

You could just use filter array on the result from get items.  No need for the apply to each then.  You might want to check that the length of the filter array is equal to 1 or greater than 0 to ensure you have a match.  But it will run in 0secs.

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cheers,
Damien


P.S. take a look at my new blog here and like & subscribe to my YouTube Channel thanks 😉

sudosaurus
Post Partisan
Post Partisan

Hi @DamoBird365 ,

 

Any tips on doing that, It was complex enough setting it up and getting it working as it currently stands.

 

Any help would be appreciated.

 

Thanks

rsaikrishna
Dual Super User
Dual Super User

@sudosaurus 

 

I recommend optimizing your flow and SP list with following steps:

1.  In SharePoint list "SupportDesk", Index all the columns which you are using in Query. Indexing will improve the performance. In your case, Index SharePoint list column "Ref" and any other columns. You can index upto 20 SP columns.

 

2. In your flow, Get Items action has Advanced Options such as Filter Query. Use Filter Query to get only the matched items with your condition such as Ref = <value>

rsaikrishna_0-1622649854948.png

With this, you can avoid Apply to each loop completely.

 

Try above two steps and post here if you have further questions.

 

Regards

Krishna Rachakonda

If this reply helped you to solve the issue, please mark the post as Accepted SolutionMarking this post as Accepted Solution, will help many other users to use this post to solve same or similar issue without re-posting the issue in the group. Saves a lot of time for everyone.

 

Hi @sudosaurus 

 

You can see an example of filtering arrays here https://www.youtube.com/watch?v=6nJSUNh579w&t=468s.  

 

@rsaikrishna is right though 👍 , if you are getting the string in a variable, you could use the filter parameter of the get items action, where your column equals your subjectsubstring variable.  You might still want to check the length afterwards though just to be sure you have a response.  Length -> https://www.youtube.com/watch?v=6nJSUNh579w&t=698s

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cheers,
Damien


P.S. take a look at my new blog here and like & subscribe to my YouTube Channel thanks 😉

 

sudosaurus
Post Partisan
Post Partisan

@rsaikrishna how do I get my filter query window to look like that?

 

This is mine, although I am using Logic Apps - is this easier in Power Automate?

sudosaurus_1-1622651153016.png

 

@sudosaurus 

it’s a preview mode, top right, advanced settings and enable preview. Not sure if it’s available in logic apps but it’s basically the odata filter.

 

equivalent is

yourcolumname eq ‘yourdynamicvalue’

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cheers,
Damien


P.S. take a look at my new blog here and like & subscribe to my YouTube Channel thanks 😉

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Users online (1,252)