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 / Counting attachments i...
Power Automate
Answered

Counting attachments in SharePoint list item

(0) ShareShare
ReportReport
Posted on by 10
I am trying to loop through a SharePoint list and grab the attachments from each item, if any exist.  I get the error below about an expression being invalid. The expression is supposed to count the number of attachments so I can use it in a condition.  
 
Here are two expressions I have tried separately:
 
  • length(body('Get_attachments')?['value']) > 0
  • @greater(length(outputs('Get_attachments')?['body']), 0)
 
I get an invalid expression on both.  Any help would be much appreciated.  Thanks!
 
Categories:
I have the same question (0)
  • Pstork1 Profile Picture
    69,456 Most Valuable Professional on at
    The left side of the comparison should be
     
    length(body('Get_attachments'))
     
    That will return the length of the array returned by Get_attachments.  Then set the comparison to greater than and the right side to 0

    ----------------------------------------------------------------------------------
    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
     
  • Verified answer
    CU10081606-2 Profile Picture
    10 on at
    After trying so many different formulas, this worked for me  length(outputs('Get_attachments')?['body'])
  • Pstork1 Profile Picture
    69,456 Most Valuable Professional on at
     In case someone else comes looking here.  
     
    outputs('Get_attachments')?['body']  is the same as body('Get_attachments') 
     
    Both return the array that is the body of the Get Attachments action.

    ----------------------------------------------------------------------------------
    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
     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 801

#2
Valantis Profile Picture

Valantis 602

#3
Haque Profile Picture

Haque 581

Last 30 days Overall leaderboard