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 III
Super User III

@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 III
Super User III

@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 III
Super User III

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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Apps Community Call

Monthly Power Apps Community Call

Did you miss the call?? Check out the Power Apps Community Call here!

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (74,179)