Expression element

<< Click to Display Table of Contents >>

Navigation:  Bizagi Studio > Process wizard > Business Rules > Business rules elements >

Expression element


Expression elements lets you enter instructions as code to carry out any type of task. Expressions can perform calculations and validations using XPath functions.


The Expressions interface has several options that allow easy interaction and accelerates the Process of writing a rule.


Business Rules Elements13




Data Model

Allows you to build XPaths to use in the expression. Additionally you can edit the data model and include values to parameter entities.


Includes a list of functions to combine the XPaths built with the data model. Functions are organized in categories and include a description and an example.

You can search for a function if you already know its syntax, or a part of it.

For more information refer to XPath functions

Library Rules

Gives access to the existing Library rules created for the project. When a rule is selected Bizagi resolves and displays the return value and the parameters and their corresponding types.

For more information refer to Library rules


Displays a list of the vocabulary that can be included in the expression. If the business rule is created as a global expression, only global vocabulary will be available. If created as application expression, the global and the application vocabulary will be available.


Allows quick access to manage variables to create, edit and delete them. Once a variable is created, select it from the drop-down list to use it in the expression.

Select parameter value

Allows quick access to parameter entities to select a value and get the id using the business key.


Allows several formatting options: save, cut, copy, paste, undo, redo, increase or decrease indent.


Upon clicking this button, Bizagi validates if each object included in the coded expression is referenced or not, and a grid listing all warnings, errors or additional information appears at the bottom of the expression editor.



The XPaths, functions, vocabularies and variables that are selected will be included at the cursor insertion point.

There is a size limit for Expressions of 100.000 characters which in average is 1000 lines. When an expression reaches 1000 lines we strongly suggest dividing it in several expressions to avoid problems at runtime.


Bizagi uses IntelliSense that helps speed up the process of coding expressions, by reducing typos and common mistakes.

As a user types, Bizagi will provide quick data navigation and access to API functions.

With IntelliSense users can type '<' and the data model will be displayed, filtering by the context of the expression. We strongly suggest using IntelliSense to avoid typing the incorrect attribute or entity name.

As a user types the beginning of the method (i.e. Me, CHelper), Bizagi will display its available functions.


Currently IntelliSense does not display attributes that are inherited.


Business Rules Elements40


We used the expression element in a previous example, if you want to review it please refer to: Expression element example


The Validate option helps you review your rule, validate the element's references and inform of inconsistencies, errors and warnings.

Elements present in the rule will be highlighted: red for errors, yellow for warnings and green for general information; if you hover the mouse over a highlighted elements, a tooltip with additional information is shown. Additionally a table showing details about the highlighted elements appears on the bottom of the screen. When you click a row of this table your cursor will be located at that occurrence.


Where to use business rules84


The references checked by the validation are:







Library families

Library rules



Syntax errors are also checked, when one of them is found, no other validations are made. The table shows the error and what is expected.


Where to use business rules85


The following elements are not taken into account when a validations is performed:

Non declared variables

Component library methods

Number of parameters of a library rule


Bizagi also runs an automatic validation when you finish editing an expression. When you click OK to close the expression and you have some type of coding error, a window appears warning you that there are mistakes in the expression. You can choose to not continue, to go back to the expression and fix the errors.





In a Purchase Request process, when the purchase has been approved it is necessary to perform quotations and select the best supplier.

However, it is required to include a specific number of quotations for the selection process. The user will not be able to continue unless the required number of quotations have been reached.


We will use an expression element to evaluate if the required number of quotations have been included. If not, a validation message will be sent to the end user to correct the situation.


Add an Expression element to the business rule and name it.


Business Rules Elements14



Create an If function to evaluate the number of quotations required versus the number of quotations included.

As the first parameter include the number of quotations required using the Data Model option.


Business Rules Elements15


Include the Quotations entered using the Count function found in the Data navigation category of the Function option, and include the XPath with the Data Model option.



When an XPath is included using the Data Model option, it includes the angle brackets. REMEMBER TO DELETE THE ANGLE BRACKETS WHEN USING XPath FUNCTIONS


Include the Validation message, using the Throw Validation error function found in the Data Validation category.



Business Rules Elements16


The final code will be:


if (<PurchaseRequest.NumberOfQuotationsRequir> > <count(PurchaseRequest.Quotation)>)

CHelper.ThrowValidationError("You need at least " + <PurchaseRequest.NumberOfQuotationsRequir> +"quotations");



Always use double equal signs ( == ) when performing value comparisons. The single equal sign corresponds to an assignment operator and will always be true.