Search Component - filter by a field value on model

Griffin BrownGriffin Brown Member
edited February 4 in Ideas
Is it possible to filter my results from the Search Component by a field value from a model?

Here's my feeble attempt:

<condition type="fieldvalue" field="Goal_Discipline__c" enclosevalueinquotes="true" value="{{$Model.Auth.data.0.Case__r.Case_Type__c}}"/>
4
4 votes

Under Consideration · Last Updated

Comments

  • edited June 2018
    Griffin,

    I don't think there is a way to filter the results in the Search Component.  I have setup pages that are used for searching where I prompt for specific search fields (like first name and last name), then use a button to activate and set the conditions for my model, and query to load the records.  You can then have table filters to further reduce the list.

    Is this what you are trying to do?

    Thanks,

    Bill
  • Griffin BrownGriffin Brown Member
    edited June 2016
    So, you can filter the Search Component, but you have to do it through the HTML. For instance, I have an object called "Phrases" and I filter it so that only phrases with "PhraseType="Goal" are displayed. I do it by putting this nested under the <Conditions> tag

    <condition type="fieldvalue" value="Goal" enclosevalueinquotes="true" field="Phrase_Type__c"/>




    So, my question is, can I make the 'value' parameter in that tag equal to a value from a model as opposed to a static string.
  • edited July 2016
    Griffin, I think this is what you are looking for: http://help.skuid.com/m/11720/l/325187-skuid-sfdc Your 'hacking' of the conditions led me to think there must be an API there. Thanks for finding this! Bill
  • Griffin BrownGriffin Brown Member
    edited July 2016
    You're a fine American, Bill
  • GaryGary Member
    edited June 2018
    It'd be great to have this as a standard feature of the Search component.

    I've been using lookup fields for months and didn't even see the Search component until recently. I love the on select actions. But not being able to add filters though means there are use cases where it won't fit the bill.

    Any chance this'll be added to a future release? And is there any way to achieve this in the meantime? I understand Bill's suggestion, but it means the drop down no longer appears.

    Griffin, I thought you were talking about manually writing conditions into the page's XML. I looked at this, the search component doesn't have a <conditions> node, and I tried to put one in, but it doesn't appear to do anything. Am I misunderstanding? Or not trying hard enough?
  • Karen WaldschmittKaren Waldschmitt Skuid Mod, Admin 🛠️ 
    edited March 2017
    Hi~

    Glad Bill was able to help you out on this, Griffin.

    As Gary suggested, I'll change this to an Idea Under consideration for our developers to consider for a future release.

    Thanks!
    Karen 
  • edited June 2018
    Hi Bill, I am not sure how to leverage this API to accomplish what griffin is attempting to do. I too am trying to pass a global merge value into the the XML with no success. Could you perhaps elaborate how to leverage this API to achieve the same result (filtered results on the search component)
  • edited June 2018
    Could you perhaps elaborate how to leverage the API to achieve the same result (filtered results on the search component)?
  • edited June 2018
    Little late to the party but perhaps this could help someone:
    https://community.skuid.com/skuid/topics/search-component-filter
  • Mark DeSimoneMark DeSimone Skuid Mod 🛠️ 
    edited February 4
    Michael, thanks very much for looping the other conversation in.

    For easy access, here's the link Michael shared: https://community.skuid.com/skuid/topics/search-component-filter. In that conversation, Zach posts a way to tweak the Search Component's XML to add a condition the same way you might see in a model. The caveat is that making changes via XML can sometimes yield unpredictable results, but I was able to build off of Zach's information and get this working in my environment. What I did was I first set up two models, such that one model had a condition that was looking at a field in the other. In this case, I have an account detail model, as well as a list of other accounts whose industry match that first account. After I set up these models and conditions correctly, I transplanted the condition XML from the secondary 'list' model into the Search conditions, like Zach described. It's working for me - does this work for you as well?
    <skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="true" useviewportmeta="true" showheader="true">
        <models>
            <model id="AccountDetail" limit="1" query="true" createrowifnonefound="false" datasource="salesforce" sobject="Account">
                <fields>
                    <field id="RecordTypeId"/>
                    <field id="Name"/>
                    <field id="Industry"/>
                </fields>
                <conditions>
                    <condition type="param" value="id" operator="=" enclosevalueinquotes="true" field="Id"/>
                </conditions>
                <actions/>
            </model>
            <model limit="100" query="true" createrowifnonefound="false" datasource="salesforce" sobject="Account" id="AccountsWithSameIndustry">
                <fields>
                    <field id="RecordTypeId"/>
                    <field id="Industry"/>
                    <field id="Name"/>
                </fields>
                <conditions>
                    <condition type="modelmerge" value="" field="Industry" operator="=" mergefield="Industry" novaluebehavior="deactivate" model="AccountDetail" enclosevalueinquotes="true"/>
                </conditions>
                <actions/>
            </model>
        </models>
        <components>
            <wrapper uniqueid="sk-13NO-260">
                <components>
                    <search uniqueid="sk-13Mg-1220" soslfields="Name Fields">
                        <objects>
                            <object datasource="salesforce" id="Account" displaytemplate="{{Name}} - {{Industry}}" fields="Industry" orderby="Name DESC">
                                <fields>
                                    <field id="Name"/>
                                    <field id="Industry"/>
                                </fields>
                                <conditions>
                                    <condition type="modelmerge" value="" field="Industry" operator="=" mergefield="Industry" novaluebehavior="deactivate" model="AccountDetail" enclosevalueinquotes="true"/>
                                </conditions>
                            </object>
                        </objects>
                    </search>
                </components>
                <styles>
                    <styleitem type="background"/>
                    <styleitem type="border" padding="all">
                        <styles>
                            <styleitem property="padding" value="88px"/>
                            <styleitem property="box-sizing" value="border-box"/>
                        </styles>
                    </styleitem>
                    <styleitem type="size"/>
                </styles>
            </wrapper>
            <grid uniqueid="sk-13Lu-878" rowgutter="16px" columngutter="16px">
                <divisions>
                    <division behavior="flex" minwidth="100px" ratio="1">
                        <components>
                            <pagetitle model="AccountDetail" uniqueid="sk-13M0-971">
                                <maintitle>
                                    <template>{{Name}}</template>
                                </maintitle>
                                <subtitle>
                                    <template>{{Model.label}}</template>
                                </subtitle>
                                <actions/>
                            </pagetitle>
                            <basicfieldeditor showheader="true" showsavecancel="true" showerrorsinline="true" model="AccountDetail" uniqueid="sk-13Ls-844" mode="read">
                                <columns>
                                    <column width="100%" uniqueid="sk-13Ls-840">
                                        <sections>
                                            <section title="Section A" uniqueid="sk-13Ls-841">
                                                <fields>
                                                    <field uniqueid="sk-13Ls-845" id="RecordTypeId"/>
                                                    <field uniqueid="sk-13Ls-846" id="Name"/>
                                                    <field uniqueid="sk-13Ls-847" id="Industry"/>
                                                </fields>
                                            </section>
                                        </sections>
                                    </column>
                                </columns>
                            </basicfieldeditor>
                        </components>
                    </division>
                    <division behavior="flex" verticalalign="top" minwidth="100px" ratio="1">
                        <components>
                            <skootable showconditions="true" showsavecancel="true" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" hideheader="false" hidefooter="false" pagesize="10" alwaysresetpagination="false" createrecords="true" model="AccountsWithSameIndustry" buttonposition="" mode="read" allowcolumnreordering="true" responsive="true" uniqueid="sk-13Lo-720" heading="Accounts with matching industry">
                                <fields>
                                    <field id="Name" hideable="true" uniqueid="fi-13Lz-927"/>
                                    <field id="Industry" uniqueid="fi-13Lo-722"/>
                                </fields>
                                <rowactions>
                                    <action type="edit"/>
                                    <action type="delete"/>
                                </rowactions>
                                <massactions usefirstitemasdefault="true">
                                    <action type="massupdate"/>
                                    <action type="massdelete"/>
                                </massactions>
                                <views>
                                    <view type="standard"/>
                                </views>
                            </skootable>
                        </components>
                    </division>
                </divisions>
                <styles>
                    <styleitem type="background" bgtype="none"/>
                </styles>
            </grid>
        </components>
        <resources>
            <labels/>
            <javascript/>
            <css/>
            <actionsequences uniqueid="sk-13K9-293"/>
        </resources>
        <styles>
            <styleitem type="background" bgtype="none"/>
        </styles>
    </skuidpage>
  • edited June 2018
    Hey Mark! Thanks a bunch! This worked perfectly. I dont think I woulda been able to figure out the right XML myself. For the record I needed my search component to search only contacts related to the account detail I was viewing. The XML is:
    <conditions>    <condition type="modelmerge" value="" field="AccountId" fieldtargetobjects="Account" operator="=" model="SelectedAccount" enclosevalueinquotes="true" mergefield="Id" novaluebehavior="deactivate"/> </conditions>
Sign In or Register to comment.