0

Searching within a view element with a Search field

I have a view element on a page. I would like to be able to search within this view. I have created a search field named Search. However, I am unable to perform the search. The code I inserted into the view is as follows: 
let search := Search;
if search != "" then
    select Products where contains(lower(text(Brand)), lower(search))
else
    select Products
end
Unfortunately, this does not work. My view remains empty (but it is populated if I enter select Products).
What am I doing wrong? 

Thank you

4 replies

null
    • Fred
    • 2 days ago
    • Reported - view

    I'm not sure what you mean by:

    (but it is populated if I enter select Products)

    You may want to try changing line 2 to:

    let search := Search;
    if search then
        select Products where contains(lower(text(Brand)), lower(search))
    else
        select Products
    end
    

    Line 2 now says if search has data, or is not null, then...

    • pascalp
    • 2 days ago
    • Reported - view

    It works. Thank you.

      • Fred
      • yesterday
      • Reported - view

       Great to hear. Forgot to say that:

      = "" is not the same as = null

      so if you can always try write the true statement.

      When you have a moment please mark the post answered.

    • Ninox partner
    • RoSoft_Steven.1
    • yesterday
    • Reported - view

    Another approach is this:

    let mysearch := Search;

    select Products where not mysearch or Brand like mysearch

Content aside

  • Status Answered
  • yesterdayLast active
  • 4Replies
  • 25Views
  • 3 Following