cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Condition on "Get Item" action (sharepoint)

Hi,

 

In my flow I have a "get item" action based on ID

And I want to put a condition in this action : 

 

If it finds no item : create an item with the ID 

Else : update the item

 

I launch my flow but when it don't find item the "get item" return an error ... "item not found"

 

flow1.png

 

It doesn't go to the next step (condition)

 

flow2.png

 

The condition is : length(outputs('Get_items')?['body/value']) is equal to 0

If the length is 0, the item doesn’t exist yet, I can create it. If it’s not 0, the item already exists and I can use the ID from ‘Get items’ to update it.

 

But the flow failed when he doesn't found item in the "get item" action ...

1 REPLY 1
Expiscornovus
Super User
Super User

Hi @Anonymous,

 

Because there is no value field in the body you can't check for its length. I would use a slightly different approach. You can first check for the statuscode of the output and if the error message starts with Item Not Found. If that is the case you could create the item.

 

Below is an example of that approach.

 

 

outputs('Get_Item')['statusCode']

 

is equal to 404

 

AND

 

 

outputs('Get_Item')['body/message']

 

starts with Item Not Found

novalue_checkforlength.png

 

And also make sure you configure run after has failed in the settings of your Condition action btw.

 

configurerunafter_hasfailed.png



Happy to help out! 🙂

Interested in more #PowerAutomate #SharePointOnline or #PowerVirtualAgents content?
Visit my blog, Subscribe to my YouTube channel or Follow me on Twitter


Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Users online (1,809)