Calculate Expression
Perform calculations and formulas using your data
Calculate Expression
Perform calculations, formulas, and data transformations using your workflow data. Use this to compute values, combine fields, or transform data before using it in other steps.
Technical Name: ExpressionFunc
Properties
- Execution Mode: SYNC
- Type: NATIVE
- Category: System Functions
- Function ID:
e4a7c2f1-9d83-4b5a-8c6e-f2d3e1a7b890
Input Schema
Required Parameters
| Parameter | Type | Description |
|---|---|---|
expressions | array | List of MAPL expressions to evaluate |
Optional Parameters
| Parameter | Type | Description |
|---|---|---|
variableVsValueMap | object | Map of variable names to values for evaluation |
outputVariables | array | List of variable names to include in output |
[Image placeholder: Expression function configuration]
Input Example
{
"expressions": [
"total = price * quantity",
"tax = total * 0.08",
"grandTotal = total + tax",
"discount = total > 100 ? 0.10 : 0.05"
],
"variableVsValueMap": {
"price": 25.00,
"quantity": 5
},
"outputVariables": ["total", "tax", "grandTotal", "discount"]
}Output Example
{
"total": 125.00,
"tax": 10.00,
"grandTotal": 135.00,
"discount": 0.10
}MAPL Syntax
Arithmetic Operations
sum = a + b
difference = a - b
product = a * b
quotient = a / b
remainder = a % bComparison Operations
isEqual = a == b
isNotEqual = a != b
isGreater = a > b
isLess = a < bConditional Expressions
result = condition ? valueIfTrue : valueIfFalse
status = amount > 1000 ? "high" : "low"[Image placeholder: MAPL syntax examples]
Use Cases
Price Calculations
Calculate pricing with discounts and tax:
{
"expressions": [
"subtotal = price * quantity",
"discount = subtotal > 500 ? 0.15 : subtotal > 100 ? 0.10 : 0.05",
"discountAmount = subtotal * discount",
"afterDiscount = subtotal - discountAmount",
"tax = afterDiscount * taxRate",
"total = afterDiscount + tax"
],
"variableVsValueMap": {
"price": 50,
"quantity": 12,
"taxRate": 0.08
}
}Status Determination
Determine status based on multiple conditions:
{
"expressions": [
"isPremium = customerTier == 'premium'",
"isHighValue = orderTotal > 1000",
"qualifiesForBonus = isPremium && isHighValue",
"bonusAmount = qualifiesForBonus ? orderTotal * 0.05 : 0"
],
"variableVsValueMap": {
"customerTier": "premium",
"orderTotal": 1500
}
}[Image placeholder: Expression use cases]
Built-in Functions
Mathematical Functions
abs(x) - Absolute value
ceil(x) - Round up
floor(x) - Round down
round(x) - Round to nearest integer
sqrt(x) - Square root
min(a, b, ...) - Minimum value
max(a, b, ...) - Maximum valueString Functions
concat(a, b) - Concatenate strings
length(str) - String length
upper(str) - Convert to uppercase
lower(str) - Convert to lowercase[Image placeholder: Built-in functions reference]
Best Practices
- Clear Variable Names: Use descriptive names for clarity
- Break Complex Logic: Split complex calculations into multiple expressions
- Validate Inputs: Check for null or undefined values
- Test Edge Cases: Test with boundary values
Comparison with JavaScript
| Aspect | Expression (MAPL) | JavaScript |
|---|---|---|
| Complexity | Simple calculations | Complex logic |
| Performance | Faster | Slower |
| Syntax | Formula-like | Full programming language |
| Use Case | Math and logic | Data transformation |
[Image placeholder: Expression vs JavaScript comparison]
Related Functions
- JavaScript - Complex transformations
- SubFlow - Reusable calculation logic
[Image placeholder: Expression debugging workflow]