cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
DemoMan
Level: Powered On

Error when using Get Items to query a list

Hello Guys, Hope You can help with this one. 

 

I have a flow that needs to check if an item already exist on a Master list, if the item exist then update it, if it doesn't exist then create the item. 

 

The issue I have is when I use a "Get Items" to query the "Master List" it goes through every single item in the "Master List" checking if the values match, if they don't match then it creates the item, BUT then it moves to the next item and it tries to create it again, and again for each item it checks. it seems that is not checking the entire list and choosing to create the item or update it after it checks the list. It does this 100 times and then it fails because some of the values are unique.Flow1.JPG 


 Flow2.JPGFlow3.JPG

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Super User
Super User

Re: Error when using Get Items to query a list

The selection of the item in Get_Items ( using the filter field in the advanced settings) sorts out that I will only get 1 item or no items back. Checking for 0 might not work as a list of no items might mean that the length function will fail. What will length (null) return? In general I add a few compose actions to my logic so that I can debug the solutions. Can you add 2 compose actions just before your condition. set the first compose to the following expression: body(‘Get_items_2’)?[‘value’] and the second one to: length(body(‘Get_items_2’)?[‘value’]) Now you will know what the values are that are failing.
Community Support Team
Community Support Team

Re: Error when using Get Items to query a list

Hi @DemoMan,

 

I have made a test on my side, please refer to screenshot below to create the flow:

Capture.PNG

Capture.PNG

 

Best regards,

Alice

4 REPLIES 4
Super User
Super User

Re: Error when using Get Items to query a list

I've created a post on this. earlier this week. https://veenstra.me.uk/2018/12/03/microsoft-flow-import-list-data-from-an-excel-spreadsheet-into-sha... To do this include a query in your get items. Then check for the number of items found then have a condition that either creates or updates the lists items.
DemoMan
Level: Powered On

Re: Error when using Get Items to query a list

Hi Pieter, Thanks so much for your reply. I see that you are using the: @equals(length(body(‘Get_items_2’)?[‘value’]), 0) I'm using a similar string on my flow: @equals(length(body('Get_items')?['value']), 1) But I'm not sure this works for me, my flow checks the first item on the list for the value I'm looking for and when it sees that is not the same value I'm looking for it creates my item, it then moves to the next item and it sees that the item doesn't have the value I'm looking so it tries to create the item again, only that this time it fails because the item was already created on the flow's first run. Does your flow check all items until it finds the one that matches your value and then stops?
Super User
Super User

Re: Error when using Get Items to query a list

The selection of the item in Get_Items ( using the filter field in the advanced settings) sorts out that I will only get 1 item or no items back. Checking for 0 might not work as a list of no items might mean that the length function will fail. What will length (null) return? In general I add a few compose actions to my logic so that I can debug the solutions. Can you add 2 compose actions just before your condition. set the first compose to the following expression: body(‘Get_items_2’)?[‘value’] and the second one to: length(body(‘Get_items_2’)?[‘value’]) Now you will know what the values are that are failing.
Community Support Team
Community Support Team

Re: Error when using Get Items to query a list

Hi @DemoMan,

 

I have made a test on my side, please refer to screenshot below to create the flow:

Capture.PNG

Capture.PNG

 

Best regards,

Alice

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Watch the event on demand for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 Release Wave 2 Plan

Power Platform 2019 Release Wave 2 Plan

Features releasing from October 2019 through March 2020.

thirdimage

Flow Community User Group Member Badge

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

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Flow Community Video Gallery!

Top Kudoed Authors
Users Online
Currently online: 212 members 4,758 guests
Please welcome our newest community members: