Smart Business Rules

Modified on Thu, 8 Oct at 2:08 PM

The Smart Business Rules action lets you automatically generate or calculate a value in one field using information stored in other fields.


This is useful when you want Sales Layer to complete data automatically by applying logic rules, similar to the formulas used in connectors.


This feature is available for Categories, Products, Variants, and Custom Entities.


What the Smart Business Rules action does


When you add this action to an agent, the agent calculates a value and writes the result into a destination field.


You can configure it to:

  • Fill only empty fields
  • Overwrite existing values
  • Calculate results using a formula built from fields, values, operators, and functions


This helps reduce manual editing and keeps repetitive calculations consistent across your catalog.


Where to find it


To add this action:

  1. Open your agent configuration.
  2. Go to the Action step.
  3. Click Add action.
  4. Select Smart Business Rules.


Smart Business Rules option in the Add action menu


Once selected, the configuration window opens so you can define how the action should work.


How to configure the action


The configuration window contains the destination field, behavior options, the formula editor, the Browse fields from selector, and the Function Library.



Destination field


Choose the field where the calculated result will be saved. This is the field the agent updates after applying the rule.


Under the selector, Sales Layer shows the table where the destination field belongs, for example Product.


Behavior


Choose how the agent should write the result:

  • Only fill empty fields: the action writes a value only if the destination field is empty.
  • Overwrite existing content: the action writes the result even if the destination field already contains a value.


Formula editor


Use the Formula editor to build the rule by combining fields, fixed values, operators, and supported functions. The result of the formula is written into the destination field.


Insert fields


Type { inside the editor to open the field suggestions for the selected table. Choose a field from the list to insert it into the formula.


Inserted fields are displayed as highlighted tokens, such as {price}, so they are easier to distinguish from functions, operators, and fixed text.



Browse fields from another table


The destination table is selected by default in Browse fields from. Change this selector when you need to insert a field from a related supported entity.


The selected table controls which fields appear when you type { in the editor.


You can reference fields from related Products, Variants, Categories, and Custom Entities, provided that a relationship exists between the items.


For Custom Entities, this relationship must be established through a Related Item field.


For example, if a product is linked to a Custom Entity containing additional product information, you can use fields from that Custom Entity in a formula to calculate or populate a destination field in the product.


This allows you to reuse information stored in related entities without having to copy it manually into each product.


Autocomplete and validation


The editor suggests supported functions and catalog fields as you type. This helps you build formulas more quickly and reduces typing errors.


Sales Layer also validates the formula. If the syntax is not valid, an error such as Invalid formula syntax appears below the editor so you can correct it before saving the action.


Create with AI


The Formula editor includes a Create with AI option that allows you to generate formulas using natural language.


Instead of writing the formula manually, click Create with AI and describe what you want the Business Rule to calculate or do.


For example, you could ask AI to create a formula that calculates a final price based on the original price and a discount percentage.


AI generates a formula based on your instructions, which you can then use in the Smart Business Rules action.


This is particularly useful if you know the result you want to achieve but are not familiar with the available functions or formula syntax.


Review the generated formula before saving the action to make sure it uses the correct fields and produces the expected result.


Function Library


The Function Library appears on the right side of the configuration window. It includes a search box, category filters, and the available functions with descriptions.


Use the filter button to narrow the library by:

  • All
  • Text
  • Numeric
  • Conditional
  • Date
  • Collections



Each function card provides integrated guidance, including its description, parameters, and usage examples. Use the + button to insert a function into the formula editor.


When inserted, the function appears with the structure it expects you to complete. For example, the conditional function is inserted as if(condition, true, false).



Finish adding the action


Once the action is configured:

  1. Click Add action to save a new action, or Update action when editing an existing one.
  2. Click Next to continue creating your agent.


Smart Business Rules action added to the agent workflow


Current available functions


The Smart Business Rules action currently supports the following operations and functions.


CategoryOperator / FunctionDescriptionExample
Arithmetic+AdditionPrice + Shipping
Arithmetic-SubtractionPrice - Discount
Arithmetic*MultiplicationPrice * 1.21
Arithmetic/DivisionPrice / 100
Grouping( )Parentheses to control precedence(Price + Shipping) * 1.21
OperandsNumeric literalInteger or decimal number100, 1.21
OperandsField referenceCatalog field inserted from the editor{Price}
OperandsString literalText enclosed in single quotes'expensive', 'active'
Comparison=EqualPrice = 100
Comparison<>Not equalStatus <> 'X'
Comparison>Greater thanPrice > 100
Comparison>=Greater than or equalPrice >= 100
Comparison<Less thanStock < 10
Comparison<=Less than or equalStock <= 10
Conditionalif(cond, yes, no)Ternary conditionalif(Price > 100, 'expensive', 'cheap')
ConditionalandLogical ANDPrice > 100 and Price < 200
ConditionalorLogical ORPrice > 100 or Price < 50
Conditionalnot(cond)Logical negationnot(Price > 100)
StringLeft(field, n)First N charactersLeft(description, 10)
StringRight(field, n)Last N charactersRight(sku, 3)
StringMid(field, start, len)Substring from a positionMid(name, 2, 5)
StringLen(field)Length of the stringLen(description)
StringUpper(field)Converts text to uppercaseUpper(name)
StringLower(field)Converts text to lowercaseLower(name)
StringTrim(field)Removes leading and trailing spacesTrim(name)
StringConcat(a, b, ...)Concatenates valuesConcat(brand, ' - ', name)
StringContains(field, 'val')Checks whether a substring existsContains(name, 'pro')
StringLocalize(field, 'lang_code')Returns the value of a multilingual field in the specified languageLocalize(Price, 'en')
StringReplace(field, searched, replaced)Replaces all occurrences of a stringReplace(Description, 'centimeters', 'cm')
DateDate fieldsSupport for date attributesProduct Creation
DateToday()Current date without timeToday()
DateNow()Current date and timeNow()
DateDate(y, m, d, hh, mm, ss)Creates a specific date or datetime. hh, mm, and ss are optional.Date(2026, 3, 30)
DateAddDays(date, n)Adds or subtracts daysAddDays(Product Creation, 5)
DateAddMonths(date, n)Adds or subtracts monthsAddMonths(Today(), -6)
DateAddYears(date, n)Adds or subtracts yearsAddYears(Date(2026, 3, 30), 4)
DateYear(date)Returns the year of a dateYear(Product Creation)
DateMonth(date)Returns the month of a dateMonth(Product Creation)
DateDay(date)Returns the day of a dateDay(Product Creation)
DateDateDiff(date1, date2, 'unit')Difference between dates in days, months, or yearsDateDiff(Product Creation, Date(2026, 3, 30), 'days')
NavigationEntity.First().propertyReturns a property from a related entityCategories.First().Discount
CollectionsEntity.Any()Checks whether there is any related entityVariants.Any()
CollectionsEntity.Sum(field)Sum of a collectionVariants.Sum(Variant Price)
CollectionsEntity.Average(field)Average of a collectionVariants.Average(Stock)
CollectionsEntity.Count()Count of related itemsVariants.Count()
CollectionsEntity.Min(field)Minimum value of a collectionCategories.Min(Price)
CollectionsEntity.Max(field)Maximum value of a collectionProducts.Max(Price)
MathFormatNumber(number, decimals)Formats a number as text, rounded to the specified number of decimal placesFormatNumber(Price, 2)
MathRound(expr, dec)RoundingRound(Price * VAT, 2)


Collections are used when the related entity is one-to-many. For example, one product can have several variants. In this case, use functions such as Any, Sum, Average, Count, Min, or Max to define how the related values should be handled.


Functions planned for future iterations


CategoryOperator / FunctionDescriptionExample
MathAbs(expr)Absolute valueAbs(Price - Cost)
MathFloor(expr)Round downFloor(Price / 10)
MathCeiling(expr)Round upCeiling(Stock / PackSize)
Custom / AIai*(...)AI evaluation that may include promptsai_score(Name, Category.Name)
Custom / AIcustom*(...)Arbitrary external logiccustom_validation(SKU)


Current limitations


Keep the following limitations in mind:

  • Only Number, Status, Short Text, Long Text, and Date destination fields are supported.
  • When you reference a multilingual field directly, the formula uses its default-language value.
  • Use Localize(field, 'lang_code') when you need the value from a specific language.
  • Fields from related entities can be referenced from Products, Variants, Categories, and Custom Entities, provided that the required relationships exist.
  • Referencing fields from a Custom Entity requires a relationship established through a Related Item field.


Common Use Cases


The Smart Business Rules action can be useful when you need to:

  • Calculate a final price from existing numeric fields
  • Create a text value by combining several fields
  • Complete a field automatically when specific conditions are met
  • Build date-based rules using date fields and functions
  • Use information from related Products, Variants, Categories, or Custom Entities
  • Populate product fields using data stored in related Custom Entities
  • Update an item's Status automatically based on a formula
  • Generate formulas from natural-language instructions using Create with AI
  • Standardize repetitive calculations across many items


Best practices


Before running the action on a large set of items, check that the source fields used in the formula contain consistent values. Test the rule with a small group first to confirm that the formula returns the expected result and writes it to the correct destination field.


When referencing related entities, verify that the relationships between items are correctly configured so the formula can access the intended data.


When working with multilingual fields, remember that the default language is used unless you apply the Localize function.


If you use Create with AI, review the generated formula and test it before applying it to your catalog.

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article