Rule Types

You can create the following rule types in API Creator:
Use the icon that displays to the left of the rule in the list of rules as a visual indicator for the various rule types.
Rule Type
Icon
Description
Code Examples
Sums designated child attribute, with optional child qualification condition.
Derive
Customer.balance
as:
Sum(ordersList.amount_un_paid where is_ready = true)
Sum(children where anAttribute != null)
#
Counts designated child rows using a defined relationship, with optional child qualification condition.
Derive
Customer.big_order_count
as:
Count(ordersList where amount_total > 100)
=
Derive an attribute value using other attributes in that entity, or parent entity (changes are propagated).
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;
Copy attribute from parent on creation.
Derive
Lineitem.Price
as:
ParentCopy(product.price)
V
Multi-attribute expression of class/parent attributes that must be met for a transaction to succeed.
Validate
Customer.CheckCredit
as:
row.balance < row.credit_limit
Validate
Purchaseorder.NotEmpty
on commit as:
return row.item_count > 0
Vc
Validation runs after all rows are processed.
E
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
Layer7 Live API Creator
executes whenever a row is inserted, updated, or deleted (when you have enabled the rule for that type of event).
For more information:
See the example for
allocateFromTo
system method. For more information about this method, see The allocateFromTo System Method.
Ee
Invoke JavaScript before rule execution.
Ec
Invoke JavaScript after all rows are processed.
Ep
For inserts, fires when
Layer7 Live API Creator
maps resource rows to table rows. This occurs in advance of the other event rules and is typically used to compute primary keys.
Minimum value of a child attribute, with optional child qualification condition.
Derive
Customer.maxOrder
as:
max(ordersList where is_ready = true)
Maximum value of a child attribute, with optional child qualification condition.
Derive
Customer.maxOrder
as:
max(ordersList where is_ready = true)
Automatically inserts a parent if it does not already exist.
Create parent for GroupBy, for example,
empsales
to track total sales for employee each month.