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

Count the number of Attachments in gallery

Hi
I would like to count the number of attachments in a gallery, I used CountRows, but can't get result. My code is CountRows(ThisItem.Attachments)

Actually I would like to have an icon to show the pictures of Attachments, if there's attachment, visible is true otherwise it's false.
I set the codes for Visible of the ViewPicture icon, the icon is in the gallery.
If(CountRows(ThisItem.Attachments)>0, true, false)
It doesn't work. Would you please tell what is wrong? Any solution?
Thanks
1 ACCEPTED SOLUTION

Accepted Solutions
mdevaney
Super User
Super User

@Donglin 

What is meant by the ViewPicture Icon?  I might need a screenshot to understand better.

 

In general, you can check if a gallery item has attachments using this code.

 

!IsEmpty(ThisItem.Attachments)

 

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

4 REPLIES 4
mdevaney
Super User
Super User

@Donglin 

What is meant by the ViewPicture Icon?  I might need a screenshot to understand better.

 

In general, you can check if a gallery item has attachments using this code.

 

!IsEmpty(ThisItem.Attachments)

 

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

WarrenBelz
Super User
Super User

Hi @Donglin ,

CountRows(ThisItem.Attachments)

on a label in the gallery shows the number of attachments on each item. For a sum of the lot using AttNo as the label name and Gallery1 as the gallery would be

Sum(Gallery1.AllItems,AttNo)

As far as thumbnails, you certainly can display them from an individual attachment control with a collection - I posted this article on the subject recently, but I do not think you can do them all from a gallery.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

ViewPicture is the name of the icon.
Your codes work. And the CountRows also works. I had a mistake with my List in SharePoint, it's fixed now.
Thank you very much.

Hi WarrenBelz,
Thank you so much, your hits are also helpful to me.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,759)