Docs‎ > ‎API Creator‎ > ‎Specify your Business Rules‎ > ‎

Rule Types

You can express your transactional Business Logic for PUT, POST and DELETE operations on base tables using reactive logic and JavaScript events. Reactive is like a spreadsheet, you declare expressions for column derivations and table validations, and then Live API Creator watches for changes to referenced data and adjusts the referencing data. The Reactive Logic Tutorial explains how to use them.

  • Derivations. Rules to derive or return a column value (e.g. Sum, Count, Formula, Min/Max, Parent Copy)
  • Validations. Use to ensure the integrity of the transaction 
  • Events. Early events, row events, regular events, request and response events are JavaScript entry points to perform user-defined actions.
Rule/Logic Type       Description Example

Derive an attribute value using other attributes in that table, or parent table (changes are propagated). for conditional assignment, use JavaScript if/else, or the ternary operator ((boolean)?[true value]:[ else value]). Derive Lineitem.amount as 

 return row.part_price * row.quantity_ordered

product_billofmaterials.value as

return row.kit_number_required * row.product.price

Derive order.DueDate as

if (row.due_date === null) {
   return new Date(moment(row.placed_date).add('months', 1)
   return row.due_date; // no change

 Parent Copy
Derive attribute value from parent attribute value (unlike formula references, parent changes are not propagated)

 Derive Lineitem.Price as 


Derive attribute value by summing designated child attribute, with optional Child Qualification Condition
Note: Qualification is in in SQL Where syntax
 Derive Customer.balance as 

Sum(ordersList.amount_un_paid where is_ready = true)
Sum(children where anAttribute != null)


Derive attribute value by counting designated child rows using a defined relationship, with optional Child Qualification Condition 
Note: Qualification is in in SQL Where syntax
 Derive Customer.big_order_count as 
Count(ordersList where amount_total > 100)
 Min/Max Derive value as the min/max of designated child rows, with optional Child Qualification Condition  Derive Customer.maxOrder as 

max(ordersList where is_ready = true)


Multi-attribute expression of class/parent attributes that must be met for a transaction to succeed - return true (else exception message  is thrown); can execute as transaction rows are processed, or at commit time after all rows are processed.

 Validate Customer.CheckCredit as

row.balance < row.credit_limit

 Commit Validation Multi-attribute expression of class/parent attributes that must be met for a transaction to succeed (else exception is thrown); executes at commit time so your validation code sees the results of all rule executions for all rows (e.g., sums, counts) Validate Purchaseorder.NotEmpty on commit as 

return row.item_count > 0

More information here.

 Managed Parent
Automatically insert a parent object if it does not already exist.
 Create parent for GroupBy, e.g., empsales to track total sales for employee each month

 InsertInto Copy one or more source rows to a target class.  Useful for auditing, deep copy   if (row.baseSalary != oldRow.baseSalary)
"employee_audits", logicContext)

 Allocation  Allocates a provider amount  to  recipients,  creating allocation objects (a provider / recipient junction) for each such allocation 
    "row.amount_un_paid > 0", "placed_date a"), 

Invoke JavaScript action (often an extensible service); can execute during or after row processing, or on commit (after all rows are processed)

 see example above
 Early EventInvoke JavaScript action during row processing, before rule execution (formulas, events, validations) often used to compute foreign keys
 Commit Event Invoke JavaScript action after all rows are processed and all rules have firedoften used to send mail, start business processes, send updates to other systems, etc.
findWhere Returns a filtered, sorted collection (used in events) 
    "row.amount_un_paid > 0",
    "placed_date a")
 Syntax Formulas, events and validations must follow this syntax.

 Called on a Resource for each row returned.

 Can be used to add or remove or modify attributes.

Key Notes

  • Logic is unorderedThe Business Logic Engine invokes your rules automatically during transaction processing, ordered by their dependencies
  • Old Values. Formulas, Validations and Actions can reference not only row.attribute values, but use oldRow.attribute values, enabling you to specify state transition logic (eg, logic based on data changes)
  • Null values. Support is provided to simplify null value checking as described here
  • logicContext. Provides access to runtime services and state, such as logicNestLevel, useCaseName, services to create, read, update and delete rows, etc. Full reference here.
  • Logic Design PatternsMost requirements can be met using these patterns which leverage Forward Chaining; see the Tutorial and SysLogic.
  • ExtensibilityRules can invoke JavaScript, enabling you to meet requirements not solved by Core Rules. Judicious design can result in reusable logic, as illustrated by the pre-supplied BusinessLogic services for allocation and copy. Add JavaScript or Java JAR libraries (API Properties/Libraries tab)