I have a model on account but I would like a filter based on oppty

  • 1
  • Question
  • Updated 11 months ago
  • Answered
I have a model on account and I want to filter accounts based on Oppty amount. 

Currently there are a lot of associated oppties but I would only need Oppties based on certain Stages and record type.
I tried using UI only model but don't know how to go about it.
Photo of Jaiti

Jaiti

  • 412 Points 250 badge 2x thumb

Posted 12 months ago

  • 1
Photo of Luzie Baumgart

Luzie Baumgart, Official Rep

  • 4,096 Points 4k badge 2x thumb
Hi Jaiti, this might be easier if you use a model on Opportunities. That way you can use a model condition for the Stage, you can use filter easily and you are still able to display all the Account information though the Opportunity. I created a simple page with standard objects and fields, hope this is helpful for you:

<skuidpage personalizationmode="server" showsidebar="false" useviewportmeta="true" showheader="false">
    <models>
        <model id="Opps" limit="20" query="true" createrowifnonefound="false" datasource="salesforce" sobject="Opportunity">
            <fields>
                <field id="RecordTypeId"/>
                <field id="AccountId"/>
                <field id="Account.Name"/>
                <field id="StageName"/>
                <field id="Amount"/>
                <field id="Account.Phone"/>
                <field id="Account.CreatedDate"/>
            </fields>
            <conditions>
                <condition type="fieldvalue" value="Discovery" field="StageName" operator="=" enclosevalueinquotes="true"/>
                <condition type="fieldvalue" field="Amount" operator="gte" inactive="true" enclosevalueinquotes="false" name="__autofilter__nstart__Amount" state="filterableoff" value=""/>
                <condition type="fieldvalue" field="Amount" operator="lte" inactive="true" enclosevalueinquotes="false" name="__autofilter__nend__Amount" state="filterableoff" value=""/>
            </conditions>
            <actions/>
        </model>
    </models>
    <components>
        <pagetitle model="Opps" uniqueid="sk-3qFi-529">
            <actions/>
            <maintitle>Model on Opportunity, Model condition "Stage = Discovery", Filter on Amount</maintitle>
        </pagetitle>
        <skootable showconditions="true" showsavecancel="true" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" hideheader="false" hidefooter="false" pagesize="10" alwaysresetpagination="false" createrecords="true" model="Opps" buttonposition="" mode="read" allowcolumnreordering="true" responsive="true" uniqueid="sk-3qEJ-328">
            <fields>
                <field id="Account.Name" hideable="true" uniqueid="fi-3qG5-743"/>
                <field id="Account.Phone" hideable="true" uniqueid="fi-3qG7-753"/>
                <field id="Account.CreatedDate" hideable="true" uniqueid="fi-3qG8-762"/>
                <field id="StageName" uniqueid="fi-3qEJ-332"/>
                <field id="Amount" uniqueid="fi-3qEJ-333"/>
            </fields>
            <rowactions>
                <action type="edit"/>
                <action type="delete"/>
            </rowactions>
            <massactions usefirstitemasdefault="true">
                <action type="massupdate"/>
                <action type="massdelete"/>
            </massactions>
            <views>
                <view type="standard"/>
            </views>
            <filters>
                <filter type="numericrange" createfilteroffoption="true" affectcookies="true" autocompthreshold="25" conditionsource="auto" labelmode="auto" filtermethod="server" conditionfield="Amount" filteroffoptionlabel="All amounts"/>
            </filters>
        </skootable>
    </components>
    <resources>
        <labels/>
        <javascript/>
        <css/>
        <actionsequences uniqueid="sk-3qE0-225"/>
    </resources>
    <styles>
        <styleitem type="background" bgtype="none"/>
    </styles>
</skuidpage>
(Edited)
Photo of Luzie Baumgart

Luzie Baumgart, Official Rep

  • 4,096 Points 4k badge 2x thumb
I also tried to use the model on Accounts. After you added "Opportunities" as Child Relationship field, you can apply conditions on it, e.g. "StageName = Discovery" and "Amount > 1000".



So you will get a list of all Accounts, but you will only see filtered Opportunities. Is that the expected result? Please try the sample page below:

<skuidpage personalizationmode="server" showsidebar="false" useviewportmeta="true" showheader="false">
    <models>
        <model id="Accounts" limit="20" query="true" createrowifnonefound="false" datasource="salesforce" sobject="Account">
            <fields>
                <field id="RecordTypeId"/>
                <field id="Opportunities" type="childRelationship" limit="20">
                    <fields>
                        <field id="Amount"/>
                        <field id="StageName"/>
                        <field id="Name"/>
                    </fields>
                    <conditions>
                        <condition enclosevalueinquotes="true" operator="=" type="fieldvalue" field="StageName" value="Discovery"/>
                        <condition enclosevalueinquotes="false" operator="gt" type="fieldvalue" field="Amount" value="1000"/>
                    </conditions>
                </field>
                <field id="Name"/>
                <field id="Phone"/>
                <field id="CreatedDate"/>
            </fields>
            <conditions/>
            <actions/>
        </model>
    </models>
    <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="Accounts" buttonposition="" mode="read" allowcolumnreordering="true" responsive="true" uniqueid="sk-3qJW-344" heading="Model on Account, Child relationship condition &quot;StageName = Discovery&quot; and &quot;Amount &gt; 1000&quot;">
            <fields>
                <field id="Name" uniqueid="fi-3qJW-347"/>
                <field id="Phone" uniqueid="fi-3qJW-348"/>
                <field id="CreatedDate" uniqueid="fi-3qJW-349"/>
                <field id="Opportunities" type="CHILDREL" limit="100" uniqueid="fi-3qJW-346" allowhtml="true">
                    <label>Opportunities</label>
                    <template>&lt;b&gt;Name: {{Name}}&lt;/b&gt;&lt;br&gt;
Stage: {{StageName}}&lt;br&gt;
Amount: {{Amount}}&lt;br&gt;</template>
                </field>
            </fields>
            <rowactions>
                <action type="edit"/>
                <action type="delete"/>
            </rowactions>
            <massactions usefirstitemasdefault="true">
                <action type="massupdate"/>
                <action type="massdelete"/>
            </massactions>
            <views>
                <view type="standard"/>
            </views>
            <filters/>
        </skootable>
    </components>
    <resources>
        <labels/>
        <javascript/>
        <css/>
        <actionsequences uniqueid="sk-3qE0-225"/>
    </resources>
    <styles>
        <styleitem type="background" bgtype="none"/>
    </styles>
</skuidpage>
Photo of Jaiti

Jaiti

  • 412 Points 250 badge 2x thumb
Thanks a lot Luzie.  I was able create a field on Oppty and filter. 
Photo of Luzie Baumgart

Luzie Baumgart, Official Rep

  • 4,096 Points 4k badge 2x thumb
Great, thank you for the feedback!