Unable to render a component based on # of rows compared to variable?

  • 1
  • Question
  • Updated 3 years ago
  • (Edited)
I'm trying to render a component based on the # of rows in a model compared to a variable. I've created a generic scenario using a formula field (below), but have had the same problem with "real" number fields.

Example (should work in any instance):
<skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="false" showheader="false">   <models>
      <model id="Account" limit="20" query="true" createrowifnonefound="false" adapter="" type="" sobject="Account">
         <fields>
            <field id="Count" uionly="true" displaytype="FORMULA" label="Count" readonly="true" returntype="DOUBLE" precision="2" scale="0">
               <formula>1</formula>
            </field>
         </fields>
         <conditions>
            <condition type="param" value="account" field="Id" operator="=" enclosevalueinquotes="true" novaluebehavior="noquery"/>
         </conditions>
         <actions/>
      </model>
   </models>
   <components>
      <pagetitle model="Account" uniqueid="sk-wzJ86-349">
         <actions/>
         <maintitle>Reference to Current Model Variable</maintitle>
      </pagetitle>
      <richtext multiple="false" uniqueid="sk-wyUJ9-164" model="Account">
         <contents>&lt;p style="-webkit-user-select: auto;"&gt;Render if # of account rows = 1; # of rows = {{$Model.Account.data.length}}; variable = {{Count}}&lt;/p&gt;
</contents>
         <renderconditions logictype="and">
            <rendercondition type="fieldvalue" enclosevalueinquotes="false" fieldmodel="Account" sourcetype="modelproperty" nosourcerowbehavior="deactivate" sourceproperty="data.length" operator="=" value="{{Count}}"/>
         </renderconditions>
      </richtext>
      <richtext multiple="false" uniqueid="sk-wz1Ri-285" model="Account">
         <contents>&lt;p style="-webkit-user-select: auto;"&gt;&lt;span style="font-size: 13.3px; -webkit-user-select: auto;"&gt;Render if # of account rows &amp;gt; 1; # of rows = {{$Model.Account.data.length}}&lt;/span&gt;&lt;span style="font-size: 13.3px;"&gt;; variable = {{Count}}&lt;/span&gt;&lt;/p&gt;
</contents>
         <renderconditions logictype="and">
            <rendercondition type="fieldvalue" enclosevalueinquotes="false" fieldmodel="Account" sourcetype="modelproperty" nosourcerowbehavior="deactivate" sourceproperty="data.length" operator="gt" value="{{Count}}"/>
         </renderconditions>
      </richtext>
      <richtext multiple="false" uniqueid="sk-wz6Hs-319" model="Account">
         <contents>&lt;p style="-webkit-user-select: auto;"&gt;&lt;span style="font-size: 13.3px; -webkit-user-select: auto;"&gt;Render if # of account rows &amp;lt; 1; # of rows = {{$Model.Account.data.length}}&lt;/span&gt;&lt;span style="font-size: 13.3px;"&gt;; variable = {{Count}}&lt;/span&gt;&lt;/p&gt;
</contents>
         <renderconditions logictype="and">
            <rendercondition type="fieldvalue" enclosevalueinquotes="false" fieldmodel="Account" sourcetype="modelproperty" nosourcerowbehavior="deactivate" sourceproperty="data.length" operator="lt" value="{{Count}}"/>
         </renderconditions>
      </richtext>
      <pagetitle model="Account" uniqueid="sk-w_F2_-497">
         <maintitle>Reference to Global Merge Variable</maintitle>
         <actions/>
      </pagetitle>
      <richtext multiple="false" uniqueid="sk-w_MNQ-506" model="Account">
         <contents>&lt;p style="-webkit-user-select: auto;"&gt;&lt;span style="font-size: 13.3px; -webkit-user-select: auto;"&gt;Render if # of account rows = 1; # of rows = {{$Model.Account.data.length}}; variable = {{$Model.Account.data.0.Count}}&lt;/span&gt;&lt;/p&gt;
</contents>
         <renderconditions logictype="and">
            <rendercondition type="fieldvalue" enclosevalueinquotes="false" fieldmodel="Account" sourcetype="modelproperty" nosourcerowbehavior="deactivate" sourceproperty="data.length" operator="=" value="{{$Model.Account.data.0.Count}}"/>
         </renderconditions>
      </richtext>
      <richtext multiple="false" uniqueid="sk-w_xyl-570" model="Account">
         <contents>&lt;p style="-webkit-user-select: auto;"&gt;&lt;span style="font-size: 13.3px; -webkit-user-select: auto;"&gt;Render if # of account rows &amp;gt; 1; # of rows = {{$Model.Account.data.length}}; variable =&amp;nbsp;&lt;/span&gt;&lt;span style="font-size: 13.3px; -webkit-user-select: auto;"&gt;{{$Model.Account.data.0.Count}}&lt;/span&gt;&lt;/p&gt;
</contents>
         <renderconditions logictype="and">
            <rendercondition type="fieldvalue" enclosevalueinquotes="false" fieldmodel="Account" sourcetype="modelproperty" nosourcerowbehavior="deactivate" sourceproperty="data.length" operator="gt" value="{{$Model.Account.data.0.Count}}"/>
         </renderconditions>
      </richtext>
      <richtext multiple="false" uniqueid="sk-w-8B4-600" model="Account">
         <contents>&lt;p style="-webkit-user-select: auto;"&gt;&lt;span style="font-size: 13.3px; -webkit-user-select: auto;"&gt;Render if # of account rows &amp;lt; 1; # of rows = {{$Model.Account.data.length}}; variable = &lt;/span&gt;{{$Model.Account.data.0.Count}}&lt;/p&gt;
</contents>
         <renderconditions logictype="and">
            <rendercondition type="fieldvalue" enclosevalueinquotes="false" fieldmodel="Account" sourcetype="modelproperty" nosourcerowbehavior="deactivate" sourceproperty="data.length" operator="lt" value="{{$Model.Account.data.0.Count}}"/>
         </renderconditions>
      </richtext>
      <pagetitle model="Account" uniqueid="sk-w-wRF-668">
         <maintitle>Reference to Direct Value</maintitle>
         <actions/>
      </pagetitle>
      <richtext multiple="false" uniqueid="sk-x001E-675" model="Account">
         <contents>&lt;p style="-webkit-user-select: auto;"&gt;&lt;span style="font-size: 13.3px; -webkit-user-select: auto;"&gt;Render if # of account rows = 1; # of rows = {{$Model.Account.data.length}}; variable =&amp;nbsp;&lt;/span&gt;&lt;span style="font-size: 13.3px; -webkit-user-select: auto;"&gt;1&lt;/span&gt;&lt;/p&gt;
</contents>
         <renderconditions logictype="and">
            <rendercondition type="fieldvalue" enclosevalueinquotes="false" fieldmodel="Account" sourcetype="modelproperty" nosourcerowbehavior="deactivate" sourceproperty="data.length" operator="=" value="1"/>
         </renderconditions>
      </richtext>
      <richtext multiple="false" uniqueid="sk-x0G2l-703" model="Account">
         <contents>&lt;p style="-webkit-user-select: auto;"&gt;&lt;span style="font-size: 13.3px; -webkit-user-select: auto;"&gt;Render if # of account rows &amp;gt; 1; # of rows = {{$Model.Account.data.length}}; variable =&amp;nbsp;&lt;/span&gt;&lt;span style="font-size: 13.3px; -webkit-user-select: auto;"&gt;1&lt;/span&gt;&lt;/p&gt;
</contents>
         <renderconditions logictype="and">
            <rendercondition type="fieldvalue" enclosevalueinquotes="false" fieldmodel="Account" sourcetype="modelproperty" nosourcerowbehavior="deactivate" sourceproperty="data.length" operator="gt" value="1"/>
         </renderconditions>
      </richtext>
      <richtext multiple="false" uniqueid="sk-x0NOx-724" model="Account">
         <contents>&lt;p style="-webkit-user-select: auto;"&gt;&lt;span style="font-size: 13.3px; -webkit-user-select: auto;"&gt;Render if # of account rows &amp;lt; 1; # of rows = {{$Model.Account.data.length}}; variable =&amp;nbsp;&lt;/span&gt;&lt;span style="font-size: 13.3px; -webkit-user-select: auto;"&gt;1&lt;/span&gt;&lt;/p&gt;
</contents>
         <renderconditions logictype="and">
            <rendercondition type="fieldvalue" enclosevalueinquotes="false" fieldmodel="Account" sourcetype="modelproperty" nosourcerowbehavior="deactivate" sourceproperty="data.length" operator="lt" value="1"/>
         </renderconditions>
      </richtext>
   </components>
   <resources>
      <labels/>
      <javascript/>
      <css/>
   </resources>
   <styles>
      <styleitem type="background" bgtype="none"/>
   </styles>
</skuidpage>

I would only expect three rows to be rendered here, one for each that references rows = 1. Instead, that's the only row that is ignored.

Two more oddities:
  1. The variable seems to qualify as both greater than and less than the number of rows.
  2. If you delete the account from the query string (so that the # of rows = 0), the same thing happens.
Am I doing something wrong? Or is it just not possible to compare the # of rows against a variable? Any workarounds?

Use case: we are using this as a registration page and we want to limit the number of registrants per event (field on campaign).
Photo of Seth Leonard

Seth Leonard

  • 662 Points 500 badge 2x thumb

Posted 3 years ago

  • 1

Be the first to post a reply!