Guide to Formulas in Triggers
Create smart rules for your CRM/ERP system with powerful formulas
What are formulas?
Formulas in Elbuz allow you to create intelligent rules for triggers instead of simple fixed values. For example, instead of always setting the status to "New," you can set "VIP" for large orders or "Urgent" if the comment contains the word "urgent."
How to distinguish the formula: All formulas begin with the symbol @
| Simple meaning | Formula |
|---|---|
New order | @if(document.amount > 1000, 'VIP order', 'Regular order') |
Data sources
In formulas, you can use data from various sources:
| Source | Description | Example |
|---|---|---|
document.field_name | Document data (orders, invoices, etc.) | document.total_amount |
contractor.field_name | Counterparty/supplier details | contractor.company_name |
user.field_name | User data (if available) | user.department |
Examples of fields:
- Document fields:
document.order_number,document.total_amount,document.status,document.comments - Counterparty fields:
contractor.company_name,contractor.email,contractor.phone,contractor.type - User fields:
username,user.department,user.role,user.manager_id
Available functions
@if - Conditions ("If... then... else...")
Syntax: @if(condition, value_if_true, value_if_false)
Comparison operators:
equals- equalscontains- contains text>- more<- less>=- greater than or equal to<=- less than or equal!=- not equal
Examples:
@if(document.total_amount > 5000, 'VIP', 'Regular')
If the order amount is more than €5,000, set the status to "VIP", otherwise "Regular"@if(document.comments contains 'urgent', 'Priority', 'Normal')
If comments contain the word "urgent", set the priority to "Priority"@if(contractor.company_type equals 'LLC', 'Corporate', 'Private')
Checking the counterparty type
@json - Extracting from JSON
Syntax: @json(field_with_json, 'key')
Used when the field contains structured JSON data.
Example:
@json(document.custom_fields, '17')
Extract the value for the key "17" from the JSON in the custom_fields field
Example: If custom_fields contains {"16":"test1","17":"443355"}, the result will be 443355
@calc - Mathematical calculations
Syntax: @calc(math_expression)
Examples:
@calc(document.price * 1.2)
Increase the price by 20%@calc(document.total_amount - document.discount)
Calculate the amount after discount@calc((document.price * document.quantity) * 0.21)
Calculate VAT 21%
@concat - Concatenate text
Syntax: @concat(text1, text2, text3,...)
Examples:
@concat('Order from ', contractor.company_name)
Result: "Order from Horns and Hooves LLC"@concat(contractor.company_name, ' - ', document.order_number)
Result: "OOO Horns and Hooves - ZK-001"@concat('Amount: ', document.total_amount, '€')
Result: "Amount: 1500€"
@field - Getting the field value
Syntax: @field('source.field')
Examples:
@field('contractor.phone')
Get the counterparty's phone number@field('document.manager_id')
Get the document manager ID
Practical examples for business
Managing order statuses
VIP clients for large orders:
@if(document.total_amount >= 10000, 'VIP order', 'Regular order')
Urgent orders by comment:
@if(document.comments contains 'urgent', 'Urgent', @if(document.comments contains 'asap', 'Urgent', 'Normal'))
Automatic discounts
Discount for regular customers:
@if(contractor.customer_type equals 'Permanent', @calc(document.price * 0.95), document.price)
5% discount for regular customers
Discount for large quantities:
@if(document.quantity > 100, @calc(document.total_amount * 0.9), document.total_amount)
Formation of document descriptions
Automatic description generation:
@concat('Order #', document.order_number, ' from ', contractor.company_name, ' - ', document.total_amount, '€')
Control of invoices
Control of large deliveries:
@if(document.total_amount > 50000, 'Requires additional control', 'Standard processing')
Extracting data from additional fields
Getting a product code from JSON:
@json(document.additional_data, 'product_code')
Getting the region from settings:
@json(contractor.settings, 'region')
Complex examples (nested formulas)
Multi-level conditions:
@if(contractor.customer_type equals 'VIP', @if(document.total_amount > 5000, 'VIP Premium', 'VIP Standard'), 'Regular')
Creates different VIP levels depending on the amount
Dynamic generation of headings:
@concat(@if(document.doc_type equals 'order', 'Order', 'Invoice'), 'No', document.number, ' (', contractor.company_name, ')')
Creates different headings depending on the document type
Complex pricing with multiple conditions:
@if(contractor.customer_type equals 'VIP', @calc(document.price * 0.85), @if(document.quantity > 50, @calc(document.price * 0.9), document.price))
VIP gets 15% discount, bulk orders get 10% discount
Common mistakes
| Incorrect ❌ | Correct ✅ |
|---|---|
if(document.amount > 1000, 'VIP', 'Regular')Forgot the @ at the beginning | @if(document.amount > 1000, 'VIP', 'Regular') |
@concat(Order from ', contractor.name)Incorrect quotation marks | @concat('Order from ', contractor.name) |
@if(document.amount > 1000, 'VIP', 'Regular'Unclosed parentheses | @if(document.amount > 1000, 'VIP', 'Regular') |
Important notes:
- Make sure the field exists in your system.
- Check that all parentheses are closed correctly.
- Use correct quotation marks for text
Tips and recommendations
- Start simple: Start with basic formulas and gradually add complexity
- Test the formulas: Always test your formulas on real data.
- Use clear field names: Make the terms easy to understand
- Combine functions: Use multiple functions together to create powerful rules
- Document formulas: Add comments that explain complex logic
- Maintain readability: Break complex formulas into smaller parts whenever possible.
Expert advice: This tool will help automate many business processes and make your CRM system smarter!
Conclusion
Trigger formulas are a powerful tool for automating business processes in Elbuz. They allow you to create flexible and intelligent rules that adapt to various situations and conditions. Start with simple formulas and gradually explore more complex capabilities.

