When a formula field “depends” on another formula field, the formula field is being calculated incorrectly on page load.
Note
- The UI field that depends on the other UI field is listed last in the Field list for the model.
- During runtime, if the fields that affect the formula change, the calculations are correct.
Steps to reproduce:
- Create page using XML below
- Create an order and add an order item setting quantity equal to 10
- 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>