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

Search Item - Help in Code or Function

Hi everyone, 

 

I'm trying to write a function whose goal is to find a number listed in the field below.

I've already tried putting the code/function as in the image, but it is not allowed or doesn't execute. 

 

SortByColumns(Search(CustomGallerySample, TextSearchBox4.Text, "SampleText"), "SampleText", If(SortDescending1, SortOrder.Descending, SortOrder.Ascending))

 

Tks for support. 

4 REPLIES 4
Super User
Super User

Re: Search Item - Help in Code or Function

@Naesio 

This is not how PowerApps works...please read my response to your same question in your other posting.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Highlighted
BrianR
Level 10

Re: Search Item - Help in Code or Function

Looks like a circular reference to me....  You're setting the Default for a control (TextSearchBox4) to a value that is searching the value for that control...  

 

However over the red circle or run the "App Checker" (stethescope icon) to verify the error...  

Community Support Team
Community Support Team

Re: Search Item - Help in Code or Function

Hi @Naesio 

 

Do you want to sort by one search box's text?

You can change your formula expression as this:

Sort(Search(CustomGallerySample, TextSearchBox4.Text, "SampleText"), "SampleText", If(SortDescending1, SortOrder.Descending, SortOrder.Ascending))

 

For example:

search.PNG

 

sortSearch.gif

 

Hope this could be helpful.

 

Best Regards.

Yumia

Super User
Super User

Re: Search Item - Help in Code or Function

@Naesio 

Not sure if you saw the reply I gave you to this question in your other post, but here it is repeated for your convenience. 

-----------------------------

 

You need not worry about the Textbox to do anything.  In PowerApps, things "respond" to other controls, controls don't usually alter other things.

So, looking at your original default formula for your Gallery Items Property is the place to start.

You can see that it had two functions in it - the SortByColumns and the Search function.  You will need to apply those to your Gallery Items property as well.

Consider altering this formula for your needs:

SortByColumns(
    Search(yourDataSource, 
                TextSearchBox4.Text,
                "yourColumnYouWantToSearchInQuotes"),
    "yourColumnYouWantToSortByInQuotes",
    If(SortDescending1,
       SortOrder.Descending,
       SortOrder.Ascending)
)

This will give you similar functionality for searching and sorting that you were asking for, but you need to apply your datasource and your columns.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

Helpful resources

Announcements
firstImage

PowerApps Monthly Community Call!

Join us next Wednesday for our Demo Extravaganza, October 16, 2019 8am PDT.

firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 361 members 5,145 guests
Please welcome our newest community members: