4 Replies Latest reply on May 30, 2017 3:01 AM by SamOsman

    Portal filter by dropdown and keyword

    SamOsman

      Hi,

       

      I've got a popover on my layout used to add line items to my invoices, which works great.

       

      I've now built a search into this, which you type in, and it then finds any products that contain the word in the 'search' field, which also works.

       

      However, I now want to be able to sort by category and sub-category as a dropdown, and also be able to search. But not have to select a category if you don't want to. (I haven't added the subcategory yet, but have a field for it in the products table)

       

      At the moment it auto selects the first category in the list, and then you can add keywords. How do I change this so it doesn't auto-select a category? (Bearing in mind that some products don't have a category, in which case they are shown when you empty the category search field in the layout) I suppose it almost needs an 'all category' option which is chosen by default? Not sure how to achieve this though.

       

      I've included some screenshots of the layout and the current 'portal filter' calculation.

       

      Screen Shot 2017-05-28 at 18.35.36.png

      Screen Shot 2017-05-28 at 18.35.57.png

        • 1. Re: Portal filter by dropdown and keyword
          SteveMartino

          I'm not completely following you, maybe a sample file would help. But maybe you make a stored calculation field that concatenates the category, part number and item.  Then search that field and/or use it in the portal filter calculation expression.

          • 2. Re: Portal filter by dropdown and keyword
            bigtom

            At first I think you would get your category / subcategory selection to globals and use a script to determine if they are empty or not. Based on that use an eSQL query to pull in the matches.

             

            if it's just a keyword or a category the script defaults to the way you have it. If it's all three the query goes to work.

             

            I am sure you will get some other answers that might be better.

            • 3. Re: Portal filter by dropdown and keyword
              philmodjunk

              I wouldn't use the If function like you have. Might use case, or might use (), and, and or functions.

               

              Example for just filtering by Category:

               

              IsEmpty ( Layout::Category ) OR

              Portal::Category = Layout::Category

               

              If you don't specify a category, you get all categories.

               

              The same method works for keyword or other partial string matching. Combining both for the same search portal can get complex, but is workable if the table being searched is not so large that you get delays waiting for the portal to update.

               

              ( IsEmpty ( Layout::Category ) OR

                Portal::Category = Layout::Category )

               

              AND

               

              (IsEmpty ( Layout::Keyword ) OR

              PatternCount ( Portal::Description ; Layout::Keyword ) > 0 )

               

              Is just one possible expression that you might use.

              • 4. Re: Portal filter by dropdown and keyword
                SamOsman

                Thank you for all your comments. After implementing Phil's calculation to my portal filter, that's got it working as id like.