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

Using the With Function and Search Text Input

Hi,

 

Googling this one isnt much fun with the word "With", Im using the following piece of code to filter my gallery by the current user, it works however i also wish to use the search text function?

 

Could someone show me where it goes?

 

 

With(
    {wUser: User().FullName},
    SortByColumns(
        Filter(
            Interactions,
            NewCreatedBy.DisplayName = wUser
        ),
        "Created",
        If(
            SortDescending1,
            Ascending,
            Descending
        )
    )
)

 

I do know i can put it here

 

With(
    {wUser: User().FullName},
    SortByColumns(
        Filter(
            Interactions, NewCreatedBy.DisplayName = wUser ,
           StartsWith(Discussion, TextSearchBox1_1.Text)
        ),
        "Created",
        If(
            SortDescending1,
            Ascending,
            Descending
        )
    )
)

 

But then i get delagation issues, which is why im using With in the first place?

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
WarrenBelz
Super User
Super User

@SomeoneAwesome ,

There is really no need to use With() on that code (although it is an extremely useful function (refer this blog of mine)

SortByColumns(
    Filter(
       Interactions,
       NewCreatedBy.DisplayName = User().FullName
   ),
   "Created",
   If(
      SortDescending1,
      Ascending,
      Descending
   )
)

However, you can use it like this to manage Delegation on the Search function (note the With() output record numbers need to be under your Delegation limit)

With(
   {
      wList:
      SortByColumns(
         Filter(
            Interactions,
            NewCreatedBy.DisplayName = User().FullName
         ),
         "Created",
         If(
            SortDescending1,
            Ascending,
            Descending
         )
      )
   },
   Search(
      wList,
      YourSearchBoxName.Text,
      "SearchedField1",
      "SearchedField2"
   )
)

 

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

1 REPLY 1
WarrenBelz
Super User
Super User

@SomeoneAwesome ,

There is really no need to use With() on that code (although it is an extremely useful function (refer this blog of mine)

SortByColumns(
    Filter(
       Interactions,
       NewCreatedBy.DisplayName = User().FullName
   ),
   "Created",
   If(
      SortDescending1,
      Ascending,
      Descending
   )
)

However, you can use it like this to manage Delegation on the Search function (note the With() output record numbers need to be under your Delegation limit)

With(
   {
      wList:
      SortByColumns(
         Filter(
            Interactions,
            NewCreatedBy.DisplayName = User().FullName
         ),
         "Created",
         If(
            SortDescending1,
            Ascending,
            Descending
         )
      )
   },
   Search(
      wList,
      YourSearchBoxName.Text,
      "SearchedField1",
      "SearchedField2"
   )
)

 

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

 

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 (2,746)