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

Issue with using Length Expression for Null Values

Hi Folks, in the past when checking through values from a SharePoint list or an array for null values, I have been using the length expression to determine if the result was null.  Normally this has worked fine, and as you will see in the example below it appears to work, but the flow simply stops at that point.  If anyone can help me figure out the issue that would be awesome.  I will just detail the part of the flow that is relevant.

 

Flow1.png

 

Okay, as you will see below in a moment, the ID is coming from the filter of an array.  You will also see below that it is being passed in properly.  As for the length expression, this is what I use...

 

length(body('Get_items_2')?['value'])

 

Then under both conditions there are things that should happen based on whether or not the ID is found within the SharePoint list.  None of those things happen despite the fact that I get the green check-mark.  You will see below that the flow just seems to stop without continuing.

 

Flow2.png

From here you will see that the ID 'EX197737' from Microsoft got properly parsed and passed into the OData query.  You can also see that it returned a Null value which is correct because that incident does not exist in my SharePoint list.  So when the Flow went to the "Apply to each 8" step, it should have looked at the length(body('Get_items_2')?['value']) expression and returned a False, and therefore continued down the No path.  However, as you can see above, it simply stopped at the "Apply to each 8" step with a green check-mark and never continued (none of the steps below it were completed).

 

I have used this exact same method in other flows before without an issue.  Does anyone have any idea why this might be happening?  Any help would be appreciated!  Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
JSGarrett
Level: Powered On

Re: Issue with using Length Expression for Null Values

@edgonzales 

 

Hi Ed, I figured out the issue and wanted to post it here for other in case they run into it.  If you look all the way back at my first picture in the thread, you will notice that my "Condition 6" is inside of the "Apply to each 8".  When I rewrote the flow so that it was outside, and then the apply to each happened afterwards, everything worked like a champ.  Annoying, but what can you do.

 

Anyhow, just wanted others to be aware in case they run into it themselves.  Thanks for taking a look, I appreciate it.

View solution in original post

7 REPLIES 7
Super User
Super User

Re: Issue with using Length Expression for Null Values

@JSGarrett 

Hi there.  So, I think the difference might be that this time your results are an array, which will probably include the "value" and "[ ]" bits even if there is nothing to report.  That's why the Length() condition is going down the Yes path.

 

Maybe check out the Empty() function.  This will look inside the array, rather than just the body of results from the Get Items step.

 

Keep us posted.

-Ed-

 

 

If you liked this reply, please give it a thumbs up! If this reply has answered your question or resolved your challenge, please consider marking it as a Solution. This helps other users find it more easily via search.

JSGarrett
Level: Powered On

Re: Issue with using Length Expression for Null Values

@edgonzales 

 

Thanks for the reply.  It actually isn't going down the Yes path.  It simply isn't doing anything.  If you look at the picture, I see the check-mark, but it doesn't go down either path.  Its like it checks the condition, but doesn't do anything else.

 

Anyhow, I replaced the Length expression under "Condition 6" with each of the following (tried both)...

 

not(empty(body('Get_items_2')))

not(empty(body('Get_items_2')?['value']))

 

So that it then looked like this...

 

Flow3.png

 

However, it still ends the same.  The flow says it runs successfully, but when I check that branch, I still see this part...

 

Flow4.png

It just seems to stop.  Not sure why it is happening.  It has worked fine in other flows for me when checking against SharePoint lists.

Super User
Super User

Re: Issue with using Length Expression for Null Values

So, the green check marks are an indicator that it did go down that particular path.

Click on the condition inside the apply to each at the bottom, and share a screenshot of that so we can see what should happen further down.

 

We'll get this.  You're very close.

-Ed-

 

If you liked this reply, please give it a thumbs up! If this reply has answered your question or resolved your challenge, please consider marking it as a Solution. This helps other users find it more easily via search.

JSGarrett
Level: Powered On

Re: Issue with using Length Expression for Null Values

@edgonzales 

 

Ed, I am not sure if it is coming across properly in the screenshot, but the "Condition 6" is greyed out with the -- next to it.  It won't let me click it.  That is what I am struggling with.  The "Apply to each 8" seems like it was fine, and when I click it I see the "Condition 6" underneath it, but that is as far as it will go and I can't for the life of me understand why, especially since the flow says it ran successfully.

Super User
Super User

Re: Issue with using Length Expression for Null Values

Ah, interesting.  I think this is separate from your Length() issue, and you should absolutely be able drill all the way down into each step.  I'll step aside and ask around, too, to see if anyone has seen this behavior before.

 

Keep us posted if anything changes.

-Ed-

 

If you liked this reply, please give it a thumbs up! If this reply has answered your question or resolved your challenge, please consider marking it as a Solution. This helps other users find it more easily via search.

JSGarrett
Level: Powered On

Re: Issue with using Length Expression for Null Values

@edgonzales 

 

Hi Ed, I figured out the issue and wanted to post it here for other in case they run into it.  If you look all the way back at my first picture in the thread, you will notice that my "Condition 6" is inside of the "Apply to each 8".  When I rewrote the flow so that it was outside, and then the apply to each happened afterwards, everything worked like a champ.  Annoying, but what can you do.

 

Anyhow, just wanted others to be aware in case they run into it themselves.  Thanks for taking a look, I appreciate it.

View solution in original post

Super User
Super User

Re: Issue with using Length Expression for Null Values

Weird, but ok. 🙂 glad it's all sorted out.  A tip to make things easier going forward.  Click the three dots at the top right of the actions, and rename them to something more meaningful.  That will make things easier in the bigger flows.  I'll mark yours as the solution so others can find it easier.  Great work!

 

-Ed-

 

 

Helpful resources

Announcements
firstImage

Power Platform Online Conference

Speakers, submit your sessions now! Call for speakers ends Feb. 10!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

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

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

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 Power Automate Community Video Gallery!

Top Solution Authors
Top Kudoed Authors (Last 30 Days)
Users online (4,326)