Skip to main content

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>&amp;lt;p style="-webkit-user-select: auto;"&amp;gt;Render if # of account rows = 1; # of rows = {{$Model&#46;Account&#46;data&#46;length}}; variable = {{Count}}&amp;lt;/p&amp;gt;
</contents>
<renderconditions logictype="and">
<rendercondition type="fieldvalue" enclosevalueinquotes="false" fieldmodel="Account" sourcetype="modelproperty" nosourcerowbehavior="deactivate" sourceproperty="data&#46;length" operator="=" value="{{Count}}"/>
</renderconditions>
</richtext>
<richtext multiple="false" uniqueid="sk-wz1Ri-285" model="Account">
<contents>&amp;lt;p style="-webkit-user-select: auto;"&amp;gt;&amp;lt;span style="font-size: 13&#46;3px; -webkit-user-select: auto;"&amp;gt;Render if # of account rows &amp;amp;gt; 1; # of rows = {{$Model&#46;Account&#46;data&#46;length}}&amp;lt;/span&amp;gt;&amp;lt;span style="font-size: 13&#46;3px;"&amp;gt;; variable = {{Count}}&amp;lt;/span&amp;gt;&amp;lt;/p&amp;gt;
</contents>
<renderconditions logictype="and">
<rendercondition type="fieldvalue" enclosevalueinquotes="false" fieldmodel="Account" sourcetype="modelproperty" nosourcerowbehavior="deactivate" sourceproperty="data&#46;length" operator="gt" value="{{Count}}"/>
</renderconditions>
</richtext>
<richtext multiple="false" uniqueid="sk-wz6Hs-319" model="Account">
<contents>&amp;lt;p style="-webkit-user-select: auto;"&amp;gt;&amp;lt;span style="font-size: 13&#46;3px; -webkit-user-select: auto;"&amp;gt;Render if # of account rows &amp;amp;lt; 1; # of rows = {{$Model&#46;Account&#46;data&#46;length}}&amp;lt;/span&amp;gt;&amp;lt;span style="font-size: 13&#46;3px;"&amp;gt;; variable = {{Count}}&amp;lt;/span&amp;gt;&amp;lt;/p&amp;gt;
</contents>
<renderconditions logictype="and">
<rendercondition type="fieldvalue" enclosevalueinquotes="false" fieldmodel="Account" sourcetype="modelproperty" nosourcerowbehavior="deactivate" sourceproperty="data&#46;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>&amp;lt;p style="-webkit-user-select: auto;"&amp;gt;&amp;lt;span style="font-size: 13&#46;3px; -webkit-user-select: auto;"&amp;gt;Render if # of account rows = 1; # of rows = {{$Model&#46;Account&#46;data&#46;length}}; variable = {{$Model&#46;Account&#46;data&#46;0&#46;Count}}&amp;lt;/span&amp;gt;&amp;lt;/p&amp;gt;
</contents>
<renderconditions logictype="and">
<rendercondition type="fieldvalue" enclosevalueinquotes="false" fieldmodel="Account" sourcetype="modelproperty" nosourcerowbehavior="deactivate" sourceproperty="data&#46;length" operator="=" value="{{$Model&#46;Account&#46;data&#46;0&#46;Count}}"/>
</renderconditions>
</richtext>
<richtext multiple="false" uniqueid="sk-w_xyl-570" model="Account">
<contents>&amp;lt;p style="-webkit-user-select: auto;"&amp;gt;&amp;lt;span style="font-size: 13&#46;3px; -webkit-user-select: auto;"&amp;gt;Render if # of account rows &amp;amp;gt; 1; # of rows = {{$Model&#46;Account&#46;data&#46;length}}; variable =&amp;amp;nbsp;&amp;lt;/span&amp;gt;&amp;lt;span style="font-size: 13&#46;3px; -webkit-user-select: auto;"&amp;gt;{{$Model&#46;Account&#46;data&#46;0&#46;Count}}&amp;lt;/span&amp;gt;&amp;lt;/p&amp;gt;
</contents>
<renderconditions logictype="and">
<rendercondition type="fieldvalue" enclosevalueinquotes="false" fieldmodel="Account" sourcetype="modelproperty" nosourcerowbehavior="deactivate" sourceproperty="data&#46;length" operator="gt" value="{{$Model&#46;Account&#46;data&#46;0&#46;Count}}"/>
</renderconditions>
</richtext>
<richtext multiple="false" uniqueid="sk-w-8B4-600" model="Account">
<contents>&amp;lt;p style="-webkit-user-select: auto;"&amp;gt;&amp;lt;span style="font-size: 13&#46;3px; -webkit-user-select: auto;"&amp;gt;Render if # of account rows &amp;amp;lt; 1; # of rows = {{$Model&#46;Account&#46;data&#46;length}}; variable = &amp;lt;/span&amp;gt;{{$Model&#46;Account&#46;data&#46;0&#46;Count}}&amp;lt;/p&amp;gt;
</contents>
<renderconditions logictype="and">
<rendercondition type="fieldvalue" enclosevalueinquotes="false" fieldmodel="Account" sourcetype="modelproperty" nosourcerowbehavior="deactivate" sourceproperty="data&#46;length" operator="lt" value="{{$Model&#46;Account&#46;data&#46;0&#46;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>&amp;lt;p style="-webkit-user-select: auto;"&amp;gt;&amp;lt;span style="font-size: 13&#46;3px; -webkit-user-select: auto;"&amp;gt;Render if # of account rows = 1; # of rows = {{$Model&#46;Account&#46;data&#46;length}}; variable =&amp;amp;nbsp;&amp;lt;/span&amp;gt;&amp;lt;span style="font-size: 13&#46;3px; -webkit-user-select: auto;"&amp;gt;1&amp;lt;/span&amp;gt;&amp;lt;/p&amp;gt;
</contents>
<renderconditions logictype="and">
<rendercondition type="fieldvalue" enclosevalueinquotes="false" fieldmodel="Account" sourcetype="modelproperty" nosourcerowbehavior="deactivate" sourceproperty="data&#46;length" operator="=" value="1"/>
</renderconditions>
</richtext>
<richtext multiple="false" uniqueid="sk-x0G2l-703" model="Account">
<contents>&amp;lt;p style="-webkit-user-select: auto;"&amp;gt;&amp;lt;span style="font-size: 13&#46;3px; -webkit-user-select: auto;"&amp;gt;Render if # of account rows &amp;amp;gt; 1; # of rows = {{$Model&#46;Account&#46;data&#46;length}}; variable =&amp;amp;nbsp;&amp;lt;/span&amp;gt;&amp;lt;span style="font-size: 13&#46;3px; -webkit-user-select: auto;"&amp;gt;1&amp;lt;/span&amp;gt;&amp;lt;/p&amp;gt;
</contents>
<renderconditions logictype="and">
<rendercondition type="fieldvalue" enclosevalueinquotes="false" fieldmodel="Account" sourcetype="modelproperty" nosourcerowbehavior="deactivate" sourceproperty="data&#46;length" operator="gt" value="1"/>
</renderconditions>
</richtext>
<richtext multiple="false" uniqueid="sk-x0NOx-724" model="Account">
<contents>&amp;lt;p style="-webkit-user-select: auto;"&amp;gt;&amp;lt;span style="font-size: 13&#46;3px; -webkit-user-select: auto;"&amp;gt;Render if # of account rows &amp;amp;lt; 1; # of rows = {{$Model&#46;Account&#46;data&#46;length}}; variable =&amp;amp;nbsp;&amp;lt;/span&amp;gt;&amp;lt;span style="font-size: 13&#46;3px; -webkit-user-select: auto;"&amp;gt;1&amp;lt;/span&amp;gt;&amp;lt;/p&amp;gt;
</contents>
<renderconditions logictype="and">
<rendercondition type="fieldvalue" enclosevalueinquotes="false" fieldmodel="Account" sourcetype="modelproperty" nosourcerowbehavior="deactivate" sourceproperty="data&#46;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).

Be the first to reply!

Reply