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

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
Highlighted

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.

View solution in original post

Highlighted
Community Support
Community Support

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

View solution in original post

4 REPLIES 4
Highlighted

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.
Highlighted
Helper I
Helper I

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?
Highlighted

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.

View solution in original post

Highlighted
Community Support
Community Support

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

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Upcoming Events

Experience what’s next for Power Automate

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Top Solution Authors
Top Kudoed Authors
Users online (3,127)