cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

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

@Anonymous 

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

@Anonymous 

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

WarrenBelz
Super User
Super User

Hi @Anonymous ,

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.

Anonymous
Not applicable

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.
Anonymous
Not applicable

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

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,077)