cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Alison1
Helper III
Helper III

Sorting gallery title A-Z on start

Hi all, I have a gallery which I would like to start A-Z OnStart, but it isn't working for me.

 

This is the code I am using which puts the last updated item to the top of the gallery and allows me to sort the title A-Z with a button, however I would like the gallery to be sorted A-Z on start of the app as well.

 

If(varSortTitle,Sort(Filter([@'MIM - Customer Database'],CustomerSearch.Text in Title&ShortTitle),Title),Sort(Filter([@'MIM - Customer Database'],CustomerSearch.Text in Title&ShortTitle),Modified,Descending))

 

I tried Set(varSortTitle, true); OnStart which didn't work.  Any help would be appreciated.

 

Thanks

 

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Alison1 ,

And there lies your problem . . . you have used Set (a Global Variable) at App OnStart then UpdateContext on the screen - they are actually two separate Variables, with the Context Variable taking precedent on the screen it belongs on. Drop the one at App OnStart and put this OnVisible of the screen

UpdateContext({varSortTitle: true})

 

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.

Visit my blog Practical Power Apps

View solution in original post

5 REPLIES 5
WarrenBelz
Super User
Super User

Hi @Alison1 ,

Do you have any other references to varSortTitle in the App - go to your left Search icon (bottom item) and look for it. Also put a label on the screen with varSortTitle and see if it says true or false. What is Title&ShortTitle ?

Alison1
Helper III
Helper III

Hi @WarrenBelz 

 

  • I have it on OnSelect of a button UpdateContext({varSortTitle: false}); this is so when I submit my form the last edited item is at the top of the gallery.
  • varSortTitle is false on the label.
  • So I have 2 titles for each item, a longer title and a shorter title and I need to be able to search both.

 

Thank you 🙂

 

Alison1
Helper III
Helper III

This is my OnStart, I have a view variables 

 

Set(varTabSelected,8);Set(varGalDefault,{}); Set(varShowLoginPopup, true); Set(varSortTitle, true);

Hi @Alison1 ,

And there lies your problem . . . you have used Set (a Global Variable) at App OnStart then UpdateContext on the screen - they are actually two separate Variables, with the Context Variable taking precedent on the screen it belongs on. Drop the one at App OnStart and put this OnVisible of the screen

UpdateContext({varSortTitle: true})

 

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.

Visit my blog Practical Power Apps

Alison1
Helper III
Helper III

@WarrenBelz - perfect, thanks again! 🙂

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (1,726)