Confluence has been updated to version 6.15.9

Page tree
Skip to end of metadata
Go to start of metadata


############################################
# Column section for the SubTotal column
#----------------------------------------
col.iSubtotal=Subtotal
col.iSubtotal.type=number
col.iSubtotal.editable=false
col.iSubtotal.sortable=true
col.iSubtotal.formula={iMaterials}+({iLabour}*{iRate})+{iBasisOfPayment}
#col.iSubtotal.formula={iMaterials}+({iLabour}*{iRate})
#col.iSubtotal.formula={iLabour} * {iRate}
col.iSubtotal.summary=sum

Is there a way to programmatically set a null value to 0?

My users will not enter numbers in all fields at all times, but still requires a result (subtotal)

 

Solution

There are 2 ways to solve this

a) enforce a defaultValue in the column using the col.xyz.defaultValue property

b) explicitly test for the value using the ternary conditional ?: ie

col.iSubtotal.formula= ({iMaterials}?:0)+(({iLabour}?:0)*({iRate}?:0))+({iBasisOfPayment}?:0)


The last construct looks a bit weird - it is also called ['the elvis operator'|https://en.wikipedia.org/wiki/Elvis_operator].
It is equivalent to

 {iMaterials} ? {iMaterials} : 0 

 

or in more human readable language

 If the variable iMaterials is set, return the variable else return 0

 

Related information