cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Donglin
Level: Powered On

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

Re: Count the number of Attachments in gallery

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

Re: Count the number of Attachments in gallery

@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
Level 8

Re: Count the number of Attachments in gallery

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.

Donglin
Level: Powered On

Re: Count the number of Attachments in gallery

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.
Donglin
Level: Powered On

Re: Count the number of Attachments in gallery

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

Helpful resources

Announcements
New Ranks and Rank Icons in April

'New Ranks and Rank Icons in April

Read the announcement for more information!

Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (7,944)