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

Update Item if It Exists

hi there,

 

So I have a rather odd ask for help.

I have a flow that updates one list based on updates in another list. They are linked via a common ID. 

My flow runs and it "works" - it goes and finds the corresponding ID in the list and updates it. BUT I know my flow is wrong and I'm trying to understand why it works and how I can make it 'right'. I don't want it to just work, I want it to be right too. So I'm hoping one of you guys can help me figure out what to 'fix' so it makes sense.

Here is my flow:

cs024_0-1614831980996.png

cs024_1-1614832019799.png

cs024_2-1614832053683.png

I need it to update the item IF it exists BUT if I put it in the "Yes" part it never gets called as the output is always 0. 

Weirdly enough, in the "no" section it does update the right ID and seems to work. But I know that's not the proper way to do this.

 

Can someone please tell me what I did wrong and help me fix it?
Thank you for your time!

J

 

1 ACCEPTED SOLUTION

Accepted Solutions
DamoBird365
Microsoft
Microsoft

Hi @cs024 

 

I've put together the same solution as you and the condition works in that the length returns 1 as the number of elements in the get items step.

 

DamoBird365_1-1614851368631.png

 

DamoBird365_0-1614851240861.png

 

Can you take a look at the history of one of your runs and grab a copy of the output from the get items and I will try and help you get up and running.  I think your logic looks OK.

 

Damien

View solution in original post

6 REPLIES 6
DamoBird365
Microsoft
Microsoft

Hi @cs024 

 

I've put together the same solution as you and the condition works in that the length returns 1 as the number of elements in the get items step.

 

DamoBird365_1-1614851368631.png

 

DamoBird365_0-1614851240861.png

 

Can you take a look at the history of one of your runs and grab a copy of the output from the get items and I will try and help you get up and running.  I think your logic looks OK.

 

Damien

cs024
Frequent Visitor

Thanks Damien.


Here is the output from Get Items:

{"statusCode":200,"headers":{"Transfer-Encoding":"chunked","Vary":"Origin,Accept-Encoding","X-SharePointHealthScore":"3","X-MS-SPConnector":"1","X-SP-SERVERSTATE":"ReadOnly=0","DATASERVICEVERSION":"3.0","SPClientServiceRequestDuration":"56","SPRequestGuid":"e5d67cf9-fa8b-4d82-8a3d-558cd119d949","request-id":"e5d67cf9-fa8b-4d82-8a3d-558cd119d949","MS-CV":"+XzW5Yv6gk2KPVWM0RnZSQ.0","Strict-Transport-Security":"max-age=31536000","X-FRAME-OPTIONS":"SAMEORIGIN","Content-Security-Policy":"frame-ancestors 'self' teams.microsoft.com *.teams.microsoft.com *.skype.com *.teams.microsoft.us local.teams.office.com *.powerapps.com *.yammer.com *.officeapps.live.com *.stream.azure-test.net *.microsoftstream.com;","MicrosoftSharePointTeamServices":"16.0.0.21017","X-Content-Type-Options":"nosniff","X-MS-InvokeApp":"1; RequireReadOnly","Timing-Allow-Origin":"*","x-ms-apihub-cached-response":"true","Cache-Control":"max-age=0, private","Date":"Thu, 04 Mar 2021 04:13:42 GMT","P3P":"CP=\"ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI\"","X-AspNet-Version":"4.0.30319","X-Powered-By":"ASP.NET","Content-Type":"application/json; charset=utf-8","Expires":"Wed, 17 Feb 2021 04:13:43 GMT","Last-Modified":"Thu, 04 Mar 2021 04:13:43 GMT","Content-Length":"12"},"body":{"value":[]}} 

INPUT

Inputs

0

 

OUTPUTS

Outputs

0

 

I think maybe it is my filter query that is the issue?

 

Filter Query

Order_x0020_ID eq '60102003'

 

The "Order ID" is a lookup field in that list. And the right side of the "eq" is also a lookup value but I did grab its "Value" field from the dynamic content. Is there some format I need to do?

 

Thank you for your help.

J

 

hi Damien,

 

It turns out it was my filter condition that was the issue and that flow doesn't support lookup in the OData query.

My solution was to use a filter array instead of the Get Items filter query.

 

Thank you for replying to my thread though. It was really late last night when I typed my question and I couldn't think anymore.

Have a good day!

J

I'm still a bit confused by this to be honest.  If your query is Order_x0020_ID eq '60102003', does it work if you type literally just that?  Without the dynamic value?  I wonder if you need to take a look at what your dynamic value appears as - use a compose temporarily and see what is retrieved.


Damien

cs024
Frequent Visitor

I read somewhere that Lookup values are not supported in flow? Order_x0020_ID is actually a lookup field and I think that's why the result is always 0. So I added a "Filter Array" instead. I'm new to this so still learning and I thank you for your input and help. 🙂

 

 

Hey. I'm having a similar problem and have been using the filter array since the beginning. Can you maybe help me?

 

As the image below shows I've inserted a filter array from a value that comes from the parent list to be compared with the child one. Those values are unique and should match each other (they are).

 

After that, the condition means to understand from the child if it was a change in a row or if it was created (therefore I used a length (body from filter array)). In my understanding, the condition must be so that if the body from filter array is not 0 (i.e. if there is already a correspondence with the single ID from the child to its parent list), then is should just update the row.

Captura de tela 2022-09-06 141915.png

 

After that, it shows an error like below
Captura de tela 2022-09-06 142448.png

Have you seen something like this? 

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.

Users online (1,486)