Skip to main content

Logic Block Functions

Functions for executing reusable Logic Blocks from within expressions.

Run Logic Block

Executes a Logic Block and returns its outputs.

PropertyValue
CategoryLogic Block
Min Arguments1+
ReturnsDepends on Logic Block

Arguments:

#NameTypeDescription
0Logic Block NamestringName of the Logic Block to execute
1+Input ParametersvariesValues for the Logic Block inputs

Description: Executes a specified Logic Block (Formula, Decision Table, Decision Tree, Validation, or Validation Set) and returns its output values. The arguments after the Logic Block name correspond to the block's defined inputs.

Example:

Run Logic Block("CalculateDiscount", CustomerTier, OrderAmount)
→ returns the discount percentage from the CalculateDiscount block

Run Logic Block("ValidateEmail", EmailAddress)
→ returns true/false from the ValidateEmail validation block

Use Cases

Calling a Formula

If you have a Formula called CalculateTax that takes Amount and TaxRate as inputs:

Run Logic Block("CalculateTax", OrderSubtotal, TaxRate)
→ returns the calculated tax amount

Calling a Decision Table

If you have a Decision Table called DetermineShipping that takes Weight, Destination, and Priority:

Run Logic Block("DetermineShipping", PackageWeight, ShipToCountry, IsPriority)
→ returns the shipping method and cost

Calling a Validation

If you have a Validation called IsValidPhoneNumber that takes Phone:

Run Logic Block("IsValidPhoneNumber", CustomerPhone)
→ returns true if valid, false otherwise

Calling a Decision Tree

If you have a Decision Tree called ClassifyCustomer that takes Revenue, OrderCount, and AccountAge:

Run Logic Block("ClassifyCustomer", AnnualRevenue, TotalOrders, YearsSinceCreated)
→ returns the customer classification tier

Multiple Outputs

When a Logic Block returns multiple outputs (like a Decision Table), you can access specific outputs:

// If DetermineShipping returns ShippingMethod, ShippingCost, and EstimatedDays
ShippingResult = Run Logic Block("DetermineShipping", Weight, Country, Priority)

// Access individual outputs
ShippingResult.ShippingMethod
ShippingResult.ShippingCost
ShippingResult.EstimatedDays

Nested Logic Block Calls

Logic Blocks can call other Logic Blocks, enabling modular design:

// Formula: CalculateOrderTotal
// Calls other Logic Blocks for each component

Subtotal = Run Logic Block("CalculateSubtotal", LineItems)
Discount = Run Logic Block("CalculateDiscount", CustomerTier, Subtotal)
Tax = Run Logic Block("CalculateTax", Subtract(Subtotal, Discount), TaxRegion)
Shipping = Run Logic Block("DetermineShipping", TotalWeight, ShipToCountry, IsExpress)

Total = Add(Subtotal, Tax, Shipping.ShippingCost) - Discount

Best Practices

Use Descriptive Names: Name your Logic Blocks clearly so the expression reads naturally:

// Good - reads like plain English
If Condition(Run Logic Block("IsEligibleForDiscount", Customer), ApplyDiscount(), 0)

// Less clear
If Condition(Run Logic Block("Check1", C), D(), 0)

Match Input Types: Ensure the values you pass match the expected types of the Logic Block inputs.

Handle Validation Results: When calling Validation blocks, handle both true and false results:

If Condition(
Run Logic Block("ValidateOrder", Order),
ProcessOrder(Order),
RejectOrder(Order, "Validation failed")
)

Keep Dependencies Clear: Document which Logic Blocks your expression depends on for easier maintenance.