Formula Field evaluating incorrectly on page load (Skuid 7.16)

When a formula field “depends” on another formula field, the formula field is being calculated incorrectly on page load.

Note

  1. The UI field that depends on the other UI field is listed last in the Field list for the model.
  2. During runtime, if the fields that affect the formula change, the calculations are correct.

Steps to reproduce:

  1. Create page using XML below
  2. Create an order and add an order item setting quantity equal to 10
  3. Preview page choosing the order you created

Expected Result
Quantity = 10
Double Quantity = 20
“Triple The Double Quantity” = 60

Actual Result
“Trip The Double Quantity” equals 0

Sample Page XML

<skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="true" showheader="true" tabtooverride="Order">   <models>
      <model id="Order" limit="1" query="true" createrowifnonefound="false" sobject="Order">
         <fields>
            <field id="Name"/>
            <field id="CreatedDate"/>
            <field id="OrderNumber"/>
         </fields>
         <conditions>
            <condition type="param" enclosevalueinquotes="true" operator="=" field="Id" value="id"/>
         </conditions>
         <actions/>
      </model>
      <model id="OrderItem" limit="20" query="true" createrowifnonefound="false" adapter="" type="" sobject="OrderItem">
         <fields>
            <field id="AvailableQuantity"/>
            <field id="ListPrice"/>
            <field id="Id"/>
            <field id="Quantity"/>
            <field id="UnitPrice"/>
            <field id="OrderItemNumber"/>
            <field id="UIDoubleQuantity" uionly="true" displaytype="FORMULA" label="Double Quantity" readonly="true" returntype="DOUBLE">
               <formula>{{Quantity}}*2</formula>
            </field>
            <field id="UITripleTheDoubleQty" uionly="true" displaytype="FORMULA" label="Triple The Double Qty" readonly="true" returntype="DOUBLE">
               <formula>3*{{UIDoubleQuantity}}</formula>
            </field>
         </fields>
         <conditions>
            <condition type="modelmerge" value="" field="OrderId" operator="=" model="Order" enclosevalueinquotes="true" mergefield="Id" novaluebehavior="noquery"/>
         </conditions>
         <actions/>
      </model>
   </models>
   <components>
      <pagetitle model="Order" uniqueid="sk-buT4b-67">
         <maintitle>{{OrderNumber}}</maintitle>
         <subtitle>
            <template>{{Model.label}}</template>
         </subtitle>
         <actions>
            <action type="savecancel" window="self"/>
         </actions>
      </pagetitle>
      <basicfieldeditor showsavecancel="false" showheader="true" model="Order" mode="read" uniqueid="sk-buT4b-68">
         <columns>
            <column width="100%">
               <sections>
                  <section title="Basics" collapsible="no">
                     <fields>
                        <field id="OrderNumber" valuehalign="" type=""/>
                     </fields>
                  </section>
               </sections>
            </column>
         </columns>
      </basicfieldeditor>
      <skootable showconditions="true" showsavecancel="true" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" createrecords="true" model="OrderItem" buttonposition="" mode="read" uniqueid="sk-bvYn4-124">
         <fields>
            <field id="OrderItemNumber" valuehalign="" type=""/>
            <field id="AvailableQuantity"/>
            <field id="ListPrice"/>
            <field id="Quantity"/>
            <field id="UnitPrice"/>
            <field id="UIDoubleQuantity" valuehalign="" type=""/>
            <field id="UITripleTheDoubleQty"/>
         </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>
   <resources>
      <labels/>
      <css/>
      <javascript/>
   </resources>
   <styles>
      <styleitem type="background" bgtype="none"/>
   </styles>
</skuidpage>

Barry.  We previously identifed an issue with formula fields where formulas are not evaluated if they are based on another formula.  This exposes dependency issues for formulas that we have not previously handled.  We are working on this. 

Good deal, thanks Rob!

This appears to be at least improved if not resolved in 7.20.  Can someone confirm?

Thanks!

According to the release notes for 7.19 the ui-only formula fields should now work with other ui-only formula fields as inputs.

Thanks Matt.  I was still experiencing some precedence issues with 7.19 but they appear to be improved or possibly resolved in 7.20.

Skuid team?

We did fix the “Formula field cannot reference another formula field” issue in 7.19 (or 20…) .  Let us know if you are seeing other wierdness…   

Will do Rob.  If I recall correctly, I was able to reference another formula field in 7.19, but on page load the precedence of evaluation was incorrect and still resulting in the wrong value.  As of 7.20, it appears to be working as expected.  I’ll be doing some more testing over the new few days and will let you know if I run in to anything.  I think for now, we can consider this resolved as of 7.20.  Thanks!

Glad to hear this is fixed.