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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Gallery sorting preven...
Power Apps
Unanswered

Gallery sorting prevents opening of list item attachment using a gallery button

(0) ShareShare
ReportReport
Posted on by 2

Hello

 

I am very new to PowerApps and am trying to build a simple app to display sharepoint list item data. I have added filter controls to my gallery to sort columns ascending, descending and I have added an icon to open the one and only pdf attachment to each list item.

 

For the column sorting, I am using the following in the Items property for the gallery:

 

Switch(
locSortColumn,
"Name", Sort(Filter('Laboratory Users',LaboratoryID=gly_Laboratories.Selected.ID), Name.DisplayName, If(locSortAscending, Ascending, Descending)),
"Inductor", Sort(Filter('Laboratory Users',LaboratoryID=gly_Laboratories.Selected.ID), Inductor.DisplayName, If(locSortAscending, Ascending, Descending)),
"Date", Sort(Filter('Laboratory Users',LaboratoryID=gly_Laboratories.Selected.ID), Date, If(locSortAscending, Ascending, Descending)),
"Archive", Sort(Filter('Laboratory Users',LaboratoryID=gly_Laboratories.Selected.ID), Archive, If(locSortAscending, Ascending, Descending)),
Sort(Filter('Laboratory Users',LaboratoryID=gly_Laboratories.Selected.ID),Modified, Descending)
)

 

But - this prevents the attachment icons 'On Select' property from working - I am usng:

Launch(First(ThisItem.Attachments).AbsoluteUri)

 

I don't understand why this might be - when I use a simple Sort, the attachment link works again:

Sort(Filter('Laboratory Users',LaboratoryID=gly_Laboratories.Selected.ID),Modified, Descending)

 

Can anyone help me out?

Categories:
I have the same question (0)
  • zmansuri Profile Picture
    6,048 Super User 2024 Season 1 on at

    I don't know the exact solution to that but you can improve your code using variable. OnClick of the icon store column's name in the variable and instead of using switch statement and writing almost same code 5 times. Use variable in the place of column name.

     

    Sort(Filter('Laboratory Users',LaboratoryID=gly_Laboratories.Selected.ID), locSortColumn , If(locSortAscending, Ascending, Descending)),

  • jkbeer Profile Picture
    2 on at

    HI @zmansuri 

     

    Thanks for your reply, currently my column sort buttons use the following On Select:

     

    UpdateContext({
    locSortColumn: "Name",
    locSortAscending: locSortColumn<>"Name" Or !locSortAscending
    })

     

    Can you help with what I'd need to change to store the column name in a variable please?

     

    Then I can try using the SortFilter you suggest above to see if that sort out my original problem. 

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 337 Most Valuable Professional

#2
11manish Profile Picture

11manish 173

#3
Valantis Profile Picture

Valantis 86

Last 30 days Overall leaderboard