web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Check length of body/v...
Power Automate
Suggested Answer

Check length of body/value failing

(2) ShareShare
ReportReport
Posted on by 160
I have a flow that uses SharePoint Get Items. I am trying to test the length of the body/value to see if the Get Items returned anything.
 
In my condition I have length(outputs('Get Items - List B'])?['body/value']) is greater then 0, and it works fine if the Get Items returns a value however when nothing is found the flow errors out. I've used this approach many times but I am not sure if it works in all cases and might my other flows fail too when nothing is found.
 
Can is there a way to look for a null value or some other method of testing this?
Categories:
I have the same question (0)
  • Suggested answer
    Pstork1 Profile Picture
    69,558 Most Valuable Professional on at
    The easiest way to do this is to add another phrase to the condition before doing the length.  Have that Check to see if the Get items Body/value is null.  If you AND that check with the other one it will automatically go to the false side if no values are returned.  Make sure the null check is the first line.  Like this.

    ----------------------------------------------------------------------------------
    If this Post helped you, please click "Does this answer your question" and give it a like to help others in the community find the answer too!

    Paul Papanek Stork, MVP
    Blog: https://www.dontpapanic.com/blog
     
  • Suggested answer
    11manish Profile Picture
    3,345 on at
    For most scenarios, I recommend using:

    length(coalesce(body('Get_items')?['value'], createArray()))

    and checking whether it is greater than 0.
    This approach is robust, handles empty results safely, and protects against unexpected null values while remaining easy to read and maintain.
  • Suggested answer
    S-Venkadesh Profile Picture
    1,219 Super User 2026 Season 1 on at
     
    I don’t see any issue with the length() approach itself. The only thing I noticed is that the action name in your expression appears incorrect (missing underscores).
    Try recreating the expression from scratch using Dynamic Content instead of typing it manually:

     
    length(outputs('Get_Items_-_List_B')?['body/value'])

    It's a bit strange that it works when records are returned but fails when none are found, which suggests the expression may not be referencing the action correctly. Rebuilding it should resolve the issue.
     

     
    I hope this information helps! If it does, please consider giving a 👍.
    Best regards,
    S-Venkadesh
  • Suggested answer
    Valantis Profile Picture
    6,748 on at
     

    length(coalesce(outputs('Get_Items_-_List_B')?['body/value'], createArray())) is greater than 0
     
    When Get Items returns nothing, body/value can come back as null instead of an empty array, and length() throws on null. coalesce swaps null for an empty array so length() always gets something valid.

    One thing none of the replies mentioned: if you just want to check whether anything was returned, empty() is simpler than length:
    not(empty(coalesce(outputs('Get_Items_-_List_B')?['body/value'], createArray())))
    Same result, slightly cleaner to read.
     
      Best regards,

    Valantis   ✅ If this helped solve your issue, please Accept as Solution so others can find it quickly.

    ❤️ If it didn’t fully solve it but was still useful, please click “Yes” on “Was this reply helpful?” or leave a Like :).

    🏷️ For follow-ups  @Valantis.

    📝 https://valantisond365.com/ 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 289

#2
11manish Profile Picture

11manish 267

#3
David_MA Profile Picture

David_MA 205 Super User 2026 Season 1

Last 30 days Overall leaderboard