Writing a Configurable Formula

Configurable Formula functionality uses the same expression syntax and conventions supported in Configurable Validations. Please refer to the “Writing a Configurable Validation” topic for various conventions supported by the system. In addition, formula expression can include simple JAVA style if/else and for/while loop statements to run logic and derive a final field value.

Formula expression is a collection of statements and when multiple statements are included in the expression, the result evaluated from the last statement execution will be used as the field value where the formula is configured.

Examples:

(RATE * QUANTITY) – (RATE * QUANTITY * DISCOUNT)

Performance Budgeting amount fields need to typecasted to BigDecimal.

(new(“java.math.BigDecimal”,rate) * new(“java.math.BigDecimal”, quantity)) – (new(“java.math.BigDecimal”,rate) * new(“java.math.BigDecimal”,quantity) * new(“java.math.BigDecimal”,discount))

If (QUANTITY > 500) {

 (RATE * QUANTITY)  - (RATE * QUANTITY * 0.10)

} else if (QUANTITY > 250) {

(RATE * QUANTITY)  - (RATE * QUANTITY * 0.08)

} else {

(RATE * QUANTITY)  - (RATE * QUANTITY * 0.05)

}

Performance Budgeting amount fields need to typecasted to BigDecimal.

If(quantity > 500){

(new(“java.math.BigDecimal”,rate) * new(“java.math.BigDecimal”, quantity)) – (new(“java.math.BigDecimal”,rate) * new(“java.math.BigDecimal”, quantity) * 0.10)

} else if(quantity > 250){

(new(“java.math.BigDecimal”,rate) * new(“java.math.BigDecimal”, quantity)) – (new(“java.math.BigDecimal”,rate) * new(“java.math.BigDecimal”, quantity) * 0.08)

} else {

(new(“java.math.BigDecimal”,rate) * new(“java.math.BigDecimal”, quantity)) – (new(“java.math.BigDecimal”,rate) * new(“java.math.BigDecimal”, quantity) * 0.05)

}

If (QUANTITY > 500) {

return (RATE * QUANTITY)  - (RATE * QUANTITY * 0.10);

} else if (QUANTITY > 250) {

return (RATE * QUANTITY)  - (RATE * QUANTITY * 0.08);

} else {

 return (RATE * QUANTITY)  - (RATE * QUANTITY * 0.05);

}

Performance Budgeting amount fields need to typecasted to BigDecimal.

If(quantity > 500){

return (new(“java.math.BigDecimal”,rate) * new(“java.math.BigDecimal”, quantity)) – (new(“java.math.BigDecimal”,rate) * new(“java.math.BigDecimal”, quantity) * 0.10)

} else if(quantity > 250){

return (new(“java.math.BigDecimal”,rate) * new(“java.math.BigDecimal”, quantity)) – (new(“java.math.BigDecimal”,rate) * new(“java.math.BigDecimal”, quantity) * 0.08)

} else {

return (new(“java.math.BigDecimal”,rate) * new(“java.math.BigDecimal”, quantity)) – (new(“java.math.BigDecimal”,rate) * new(“java.math.BigDecimal”, quantity) * 0.05)

}