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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / The template language ...
Power Automate
Answered

The template language function 'length' expects its parameter to be an array or a string. The provided value is of type 'Null'.

(0) ShareShare
ReportReport
Posted on by 375

Sorry I have googled and seen a solution that is not working for me.

 

I am trying to find the number of matches in an SPO list.

 

I use the expression ... 

length(body('GetFilesPO')?['body/value'])
 
but I get the error 
The template language function 'length' expects its parameter to be an array or a string. The provided value is of type 'Null'.
 
Thanks
P

 

 

Categories:
I have the same question (0)
  • Sundeep_Malik Profile Picture
    6,484 on at

    Hey @pmwhelan 

     

     

    There may be many moments when you will get null values. For this I would suggest you to use the following expression:

    if(equals(length(body('GetFilesPO')?['body/value']),null),0,length(body('GetFilesPO')?['body/value']))

     

    Or the below expression:

     

     

    if(equals(body('GetFilesPO')?['body/value'],null),0,length(body('GetFilesPO')?['body/value']))

     

     

    So, I am checking if the above expression is equal to null or nor, if it equals null, then give length 0, otherwise the normal value.

     

    Hopefully this will work.

     

    If this works for you, you can marks this as a solution. You can give a thumbs up as well. 🙂

  • Verified answer
    v-dezhili-msft Profile Picture
    Microsoft Employee on at

    Hi @pmwhelan ,

    Do you want to get the number of files under the folder?

    Please try changing the formula to:
     

     

    length(outputs('GetFilesPO')?['body/value'])

     

    vdezhilimsft_0-1668498411546.png
    vdezhilimsft_1-1668498411547.png
    vdezhilimsft_2-1668498411548.png
    Best regards,
    Dezhi

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 501 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 323 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard