Adding business logic

After an application contains the appropriate objects and relationships to capture data, you will likely want to add logic that uses or transforms that data. Rollbase supports this through templates and formulas. Templates allow you to define a structure for calculating and displaying information. Templates contain tokens, which are variables that the runtime replaces with values from the object currently in scope. Formulas are interpreted as Javascript expressions, they describe how to calculate values. If a template contains formulas, the runtime first parses the merge tokens to obtain the values. Once the values are obtained, the runtime evaluates the Javascript expressions using the appropriate values.

For example, suppose an object contains fields for quantity and price and you want to calculate the price of a particular quantity. Using the tokens, {!quantity} and {!price}, which correspond to fields in the relevant object, the runtime will handle them in a formula as follows:

Formula: {!quantity} * {!price}>

Parsed formula values evaluated as Javascript: 100.0 * 5

Result: 500

The following table describes the areas of a Rollbase application where you can use templates and formulas and why you might use them.