Rule Types

You can create rule types in API Creator.
lac32
You can create the following rule types in API Creator:
Rule Type
Description
Code Examples
Derive attribute value by counting designated child rows using a defined relationship, with optional child qualification condition.
 Qualification is in SQL Where syntax.
Derive 
Customer.big_order_count
 as:
Count(ordersList where amount_total > 100)
Invoke JavaScript action (often an extensible service); can execute during or after row processing, or on a commit (after all rows are processed).
Event rules are JavaScript that get executed whenever a row is inserted, updated, or deleted (when you have enabled the rule for that type of event).
For more information:
  • About how to access row attributes and parent-relationship attributes using Expression help, see Customize your API.
  • About the list of code examples that are available for event rules, see Code Examples.
 
See the example in this table for
allocateFromTo
system method.
Derive an attribute value using other attributes in that entity, or parent entity (changes are propagated). For conditional assignment, use JavaScript if/else or the ternary operator ((boolean)
?[true value]:[else value]
).
Formula rules can access the values of the current row (
row.attribute
 values), the old row (
oldRow.attribute
 values), and the current values of parent rows. They must not access the values of grandparent rows. You can specify state transition logic (for example, logic based on data changes) using formula rules.
Formula rules return a value which is appropriate for its column. For example, a formula rule for a string column must return a string. API Creator converts numeric types automatically as needed.
For more information:
  • About how to access row attributes and parent-relationship attributes using Expression help, see Customize your API.
  • About the list of code examples that are available for formula rules, see Code Examples.
Derive 
Lineitem.amount
 as:
return row.part_price * row.quantity_ordered
Derive 
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)
else
return row.due_date; // no change
If a formula rule returns nothing, then the value of the column is unchanged:
if (row.value > 1000) // Do not change
return;
Automatically insert a parent object if it does not already exist.
Create parent for GroupBy, for example,
empsales
to track total sales for employee each month.
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)
Derive attribute value from parent attribute value (unlike formula references, parent changes are not propagated).
Derive 
Lineitem.Price
 as:
ParentCopy(product.price)
Derive attribute value by summing designated child attribute, with optional child qualification condition.
 Qualification is in SQL Where syntax.
Derive 
Customer.balance
 as:
Sum(ordersList.amount_un_paid where is_ready = true)
Sum(children where anAttribute != null)
Multi-attribute expression of class/parent attributes that must be met for a transaction to succeed. They return true (else exception message is thrown). They can execute as transaction rows are processed or at commit time so your validation code sees the results of all rule executions for all rows (for example, sums and counts). They must evaluate to a boolean value.
Validations rules can access the values of the current row (
row.attribute
values), the old row (
oldRow.attribute
values), and the current values of parent rows. You can specify state transition logic (for example, logic based on data changes) using formula rules, validation rules, and actions.
For more information about the list of code examples that are available for validation rules, see Code Examples.
Validate 
Customer.CheckCredit
 as:
row.balance < row.credit_limit
Validate 
Purchaseorder.NotEmpty
 on commit as:
return row.item_count > 0