Search Component - Filter

edited June 25, 2020 in Questions
LOVE the new Search component.  Is there a way to limit the results the users will get from a certain object?  For example... I am build a CPQ proof of concept.  I'm using the Search Component to search on the Products object, but I only want my users to see Product results where Active = TRUE.  (As well as other filters.)  Possible?

Comments

  • edited June 25, 2020
    Chandra, this is not currently supported via the Page Composer, but once we release Banzai Update 2 (at the end of this week), there will be a supported way to do this via XML, which I'll share with you now even though it is not going to work until you get Banzai Update 2:

    1. Click to edit your page's XML (bottom right corner of Page Composer)
    2. Find your Search component within the <components> XML by looking for "search", you should see something like this:

    image

    3. Now find the <object> node corresponding to the Product2 object, and find the </fields> tag. Immediately after the </fields> tag, and copy in the following XML:

    <conditions>
       <condition type="fieldvalue" field="IsActive" operator="=" value="true" enclosevalueinquotes="false"/>
    </conditions>

    4. Save your page.
    5. Wait till Banzai Update 2 comes out, and then try your search again --- assuming that your searching on the Product2 object, your records should be limited to just those Product2 records where the IsActive field is true.

  • Pat VachonPat Vachon 💎💎💎
    edited January 5, 2016
    Just had the same issue. Needed to filter and was going to add this as an idea.

    Implemented and works as expected.

    Thanks.

    :D
  • edited April 11, 2017
    This reply was created from a merged topic originally titled Search Box - Adding a WHERE condition to the SOSL Query. It'd be helpful for me to specify a WHERE statement to the SOSL query in the search component. This seems fairly straight foward given SOSL syntax.

    ExampleSOSL:
    FIND {Joe Smith}
    IN Name Fields
    RETURNING lead (name, phone Where createddate = THIS_FISCAL_QUARTER)&lt;br&gt;
    Here's my XML:
    <search uniqueid="sk-1pOUMT-385" soslfields="Name Fields" limit="5">                                 
                                     <objects>
                                        <object id="Phrase_Template__c" displaytemplate="{{Text_English__c}} {{Phrase_Type__c}}">
                                           <fields>
                                              <field id="Phrase_Type__c"/>
                                           </fields>
                                        </object>
                                     </objects>
                                  </search>


    Is there a way to write in a WHERE statement in <field id="Phrase_Template__c"/>?
  • edited December 21, 2016
    Griffin, I merged your question into Chandra's question - this can be done right now via XML, as described above.
  • edited May 23, 2016
    Hey Zach ... I tried this and it works well. I have two other wishlist items for Search and was wondering if these can be tackled in the XML also:
    1. Can we rename an object in the results? e.g. I've put a condition on the Account object results so that they only return clients. Would be great to rename the label for that object to Clients.
    2. Can we reuse the same object twice with different conditions? e.g. I want to search for clients as above, but I also use the Account object to store service providers, so I want to reuse Account, but with a different condition and label.
  • edited June 26, 2019
    Did we ever find out the answers on this?

    Also, can we do the following:
    • Sort the results
    • Filter based on a value from a model
    e.g. <condition type="fieldvalue" field="Goal_Discipline__c" enclosevalueinquotes="true" value="{{$Model.Auth.data.0.Case__r.Case_Type__c}}"/>
  • edited October 15, 2019
    I used Zach's XML and it worked like a charm. However, perhaps future versions of search could be based on a model instead of the object directly. Then you could build a model with all kinds of conditions and sorting.
  • edited April 11, 2017
    "perhaps future versions of search could be based on a model instead of the object directly"

    I agree. That would be ideal, and consistent with the rest of Skuid.
  • edited March 1, 2017
    Hi I always want to return a specific record from Account plus what ever user searches for. So I added two account object under Return objects. For one of them, I added

    <conditions>
                                                                                                                               <condition type="fieldvalue" field="Name" operator="=" value="Add New Company" enclosevalueinquotes="false"/>
                                                                                                                            </conditions>

    But searching is not working. How can I fix it? Thanks!
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!