web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Display All Attachment...
Power Apps
Unanswered

Display All Attachments from a grouped collection

(1) ShareShare
ReportReport
Posted on by 64

I have a SharePoint List with attachment columns, each record in the list has multiple attachments. I have created a grouped collection in the OnVisible property of the screen as below:

 

 

ClearCollect(ESG_THF_SP_sorted, 'ESG & THF Events');
ClearCollect(ESG_THF_SP_New, GroupBy(AddColumns('ESG & THF Events', CountryText, Country.Value), CountryText, Data))

 

 

 

On the screen, I added a gallery gal1 with items property set to new grouped collection. I inserted a nested a gallery in gal1, call it gal2 and set the items property to 

 

ThisItem.Data

 

 

and the Image to

 

First(ThisItem.Attachments).AbsoluteUri

 

 

Although this works but shows only the first attachment image for those records which has multiple attachments and doesn't show rest of the attachments.

I tried adding a third gallery and set its items property to

 

gal2.Selected.Attachments

 

 

but that doesn't work either.

How can I see all pics?

@RezaDorrani@WarrenBelz @anandm08 @ANB 

Categories:
I have the same question (0)
  • anandm08 Profile Picture
    1,936 Super User 2024 Season 2 on at

    hi @mridulbhardwaj1 ,

    Modify the OnVisible Property

    First, collect the records and then expand the attachments for each record.

     

    ClearCollect(ESG_THF_SP_sorted, 'ESG & THF Events');
    ClearCollect(ESG_THF_SP_New, GroupBy(AddColumns(ESG_THF_SP_sorted, "CountryText", Country.Value, "AttachmentsData", Attachments), "CountryText", "Data"));

     

    Update the Items Property of gal2

    1. Set the Items property of gal1 to ESG_THF_SP_New.

    2. Add a nested gallery gal2 inside gal1.

    3. Set the Items property of gal2 to display the attachments of the current item.

     

    ThisItem.Data.AttachmentsData

     

    This setup will allow gal2 to iterate over all the attachments of the current item in gal1.

    Display the Attachments

    1. Add an Image control inside gal2.

    2. Set the Image property of the Image control to the URL of the attachment.

     

    ThisItem.Value

     

    This should correctly display all the attachments for each record. The nested gallery gal2 will show all the attachment images for the selected item in gal1.

  • mridulbhardwaj1 Profile Picture
    64 on at

    Thanks @anandm08. This doesn't seem to work. The below isn't working. It seems .AttachmentsData is not available as a method

    ThisItem.Data.AttachmentsData

     

  • royg Profile Picture
    on at

    As explained by @anandm08,

    you can display each item's attachments in you nested gallery, but I think the same cannot be said about your actual requirement which was to group the attachments by Country.

    I think you have to use Flow to get the attachments data and then you can group it by the country.

    If Flow is not an option, you can use Sort and then hide repeating headers to achieve something that resembles grouping.

    In my demo items 32,34 have 1 attachment and 35 has 2 attachments:

    royg_0-1719995778524.png

    My nested gallery displays them "grouped" by expense type:

    royg_1-1719995821642.png

    To allow hiding repeating group headers, I needed to index the table rows, so I added an App Formula that serves as the Top gallery source:

     

    GallAllItems = With({items: Sort(Filter(ExpenseRefund,'Has attachments'), ExpenseType.Value)},
    Ungroup(
     ForAll(
     Sequence(CountRows(items)),
     {
     myRecord: Table(Index(items, Value)),
     RowNumber: Value
     }
     ),
     myRecord
    ));

     

     

    The code for the nested galleries (which you can paste and modify):

     

    - galAllItems:
     Control: Gallery
     Variant: variableTemplateHeightGallery
     Properties:
     Items: =GallAllItems
     DelayItemLoading: =true
     Height: =322
     Layout: =Layout.Vertical
     LoadingSpinner: =LoadingSpinner.Data
     TemplatePadding: =0
     TemplateSize: =50
     Y: =72
     ZIndex: =1
     Children:
     - galAttachments:
     Control: Gallery
     Variant: galleryVertical
     Properties:
     Items: =ThisItem.'{Attachments}'
     DelayItemLoading: =true
     Height: =(Self.TemplateHeight + Self.TemplatePadding + 5)* Self.AllItemsCount
     Layout: =Layout.Vertical
     LoadingSpinner: =LoadingSpinner.Data
     TemplatePadding: =0
     TemplateSize: =50
     Width: =630
     Y: =If(expenseType.Visible, expenseType.Height, 0)
     Children:
     - attachmentName:
     Control: Text
     Properties:
     Text: =ThisItem.DisplayName
     Height: =50
     Width: =620
     - expenseType:
     Control: Text
     Properties:
     Text: =ThisItem.ExpenseType.Value
     Weight: ='TextCanvas.Weight'.Bold
     Height: =50
     Visible: =IfError(Index(GallAllItems, ThisItem.RowNumber - 1).ExpenseType.Value, "") <> ThisItem.ExpenseType.Value
     Width: =630

     

     

     Hope this helps

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 765 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 272

Last 30 days Overall leaderboard