2 toggles set to deactivate each other on toggling on are also activating each other on toggling off

Pat VachonPat Vachon 💎💎💎
edited June 25, 2020 in Questions
<skuidpage unsavedchangeswarning="yes" personalizationmode="server" useviewportmeta="true" showsidebar="true" showheader="true" tabtooverride="Account">
<models> <model id="Account" limit="100" query="true" createrowifnonefound="false" datasource="salesforce" sobject="Account"> <fields> <field id="Name"/> <field id="Industry"/> </fields> <conditions> <condition type="fieldvalue" value="Financial" enclosevalueinquotes="true" field="Industry" state="filterableoff" inactive="true" name="IsFinancial"/> <condition type="fieldvalue" value="Financial" enclosevalueinquotes="true" field="Industry" operator="!=" state="filterableoff" inactive="true" name="NotFinancial"/> </conditions> <actions/> </model> </models> <components> <pagetitle model="Account" uniqueid="sk-Y-I-200"> <maintitle> <template>{{Model.labelPlural}}</template> </maintitle> <subtitle> <template>Home</template> </subtitle> <actions> <action type="savecancel" uniqueid="sk-Y-I-198"/> </actions> </pagetitle> <skootable showconditions="true" showsavecancel="false" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" createrecords="true" model="Account" mode="read" allowcolumnreordering="true" uniqueid="sk-Y-I-214"> <fields> <field id="Name" hideable="true" allowordering="true" uniqueid="fi-Y-H-983"/> <field id="Industry" hideable="true" uniqueid="fi-Y-g-270"/> </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="toggle" createfilteroffoption="true" affectcookies="false" autocompthreshold="25" conditionsource="manual" labelmode="auto" filtermethod="server" label="Financial Industry"> <effects> <effect action="activate" value="" condition="IsFinancial"/> <effect action="deactivate" value="" condition="NotFinancial"/> </effects> </filter> <filter type="toggle" createfilteroffoption="true" affectcookies="true" autocompthreshold="25" conditionsource="manual" labelmode="auto" filtermethod="server" label="Not Finance Industry"> <effects> <effect action="activate" value="" condition="NotFinancial"/> <effect action="deactivate" value="" condition="IsFinancial"/> </effects> </filter> </filters> </skootable> </components> <resources> <labels/> <css/> <javascript/> <actionsequences uniqueid="sk-Y-g-259"/> </resources> <styles> <styleitem type="background" bgtype="none"/> </styles> </skuidpage> 
Tagged:

Comments

  • edited October 31, 2019
    I thought it was contradictory what you're trying to do (like why are you using 2 conditions to do 1 thing), then I realized that it actually makes sense. When you toggle off IsFinancial or IsNotFinancial, you're resetting the filter, in a sense (in the scenario where there are only 2 filters).

    So 3 scenarios:
    1. Show records that industry is Financial
    2. Show records that industry is NOT Financial
    3. Show all records (when it comes to industry), aka don't filter or industry
    It almost seems buggy to me. Reason for the "almost", is that it's possible that when you toggle off the filter, it still runs both actions in the <effects> node (code block below), but in the opposite direction, which can make sense why it's activating the other condition.
    <filter type="toggle" ...>   <effects>      //when toggling off, this condition below deactivates      <effect action="activate" value="" condition="IsFinancial"/>      //when toggling off, this condition below activates  
    <effect action="deactivate" value="" condition="NotFinancial"/>
    </effects> </filter>
    So I'm not entirely sure if it's bug or feature.
    Either way, I tested out another way to achieve what you need to do using Model Actions (I think I overuse Model Actions tbh, it's cool but can totally trip you up later)
    <skuidpage unsavedchangeswarning="yes" personalizationmode="server" useviewportmeta="true" showsidebar="true" showheader="true" tabtooverride="Account">
      <models>
        <model id="Account" limit="100" query="true" createrowifnonefound="false" datasource="salesforce" sobject="Account">
          <fields>
            <field id="Name"/>
            <field id="Industry"/>
          </fields>
          <conditions>
            <condition type="fieldvalue" value="Financial" enclosevalueinquotes="true" field="Industry" state="filterableoff" inactive="true" name="IsFinancial" operator="="/>
            <condition type="fieldvalue" value="Financial" enclosevalueinquotes="true" field="Industry" operator="!=" state="filterableoff" inactive="true" name="IsNotFinancial"/>
          </conditions>
          <actions>
            <action>
              <actions>
                <action type="deactivateCondition" timeout="2000" message="IsFinancial is activated" model="Account" condition="IsNotFinancial"/>
              </actions>
              <events>
                <event>condition.activated</event>
              </events>
              <conditions>
                <condition>IsFinancial</condition>
              </conditions>
            </action>
            <action>
              <actions>
                <action type="deactivateCondition" model="Account" condition="IsFinancial"/>
              </actions>
              <events>
                <event>condition.activated</event>
              </events>
              <conditions>
                <condition>IsNotFinancial</condition>
              </conditions>
            </action>
          </actions>
        </model>
      </models>
      <components>
        <pagetitle model="Account" uniqueid="sk-Y-I-200">
          <maintitle>
            <template>{{Model.labelPlural}}</template>
          </maintitle>
          <subtitle>
            <template>Home</template>
          </subtitle>
          <actions>
            <action type="savecancel" uniqueid="sk-Y-I-198"/>
          </actions>
        </pagetitle>
        <skootable showconditions="true" showsavecancel="false" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" createrecords="true" model="Account" mode="read" allowcolumnreordering="true" uniqueid="sk-Y-I-214">
          <fields>
            <field id="Name" hideable="true" allowordering="true" uniqueid="fi-Y-H-983"/>
            <field id="Industry" hideable="true" uniqueid="fi-Y-g-270"/>
          </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="toggle" createfilteroffoption="true" affectcookies="false" autocompthreshold="25" conditionsource="manual" labelmode="auto" filtermethod="server" label="Is Not Financial Industry">
              <effects>
                <effect action="activate" value="" condition="IsNotFinancial"/>
              </effects>
            </filter>
            <filter type="toggle" createfilteroffoption="true" affectcookies="true" autocompthreshold="25" conditionsource="manual" labelmode="auto" filtermethod="server" label="Is Financial">
              <effects>
                <effect action="activate" value="" condition="IsFinancial"/>
              </effects>
            </filter>
          </filters>
        </skootable>
      </components>
      <resources>
        <labels/>
        <css/>
        <javascript/>
        <actionsequences uniqueid="sk-Y-g-259"/>
      </resources>
      <styles>
        <styleitem type="background" bgtype="none"/>
      </styles>
    </skuidpage>
  • Pat VachonPat Vachon 💎💎💎
    edited June 25, 2020
    Yup. I know about using model actions. It's what I'm using as a work around.

    I'd consider this a bug and not a feature.
  • edited November 4, 2019
    I had a discussion with Rob Hatch and learned that this might be intended behavior and not a bug. 

    The behavior is that when you have, for example, 3 conditions: A, B, and C and you have a Toggle filter that has the effects below when toggling ON:
    1. Deactivate A
    2. Deactivate B
    3. Activate C

    When the toggle is OFF, the filter ignores if A and B were initially deactivated (like in your case) and will reverse the above effects like so:
    1. Activate A
    2. Activate B
    3. Deactivate C

    So Toggle Filter only knows 2 points: Point 1 and Point 2, and all it does is go from one to the other and then back. What you need it to do is point 3, where ALL the filters are reset. So the workaround with model actions like you did, or potentially using Select Filter to set value of a condition instead of using truthy/falsy conditions (maybe?)

    (side note: I learned so much about Toggle filter from this exploration, and I'm still not sure if I'm a huge fan of this filter option, but maybe it's super helpful in other use cases *shrug*)

  • Rob HatchRob Hatch 🛠️ 
    edited November 6, 2019
    Not "might be"  -- It is intended behavior.... 
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!