Business rules in the form rules

Facebooktwitterpinterestlinkedinmail
Applies to version: 2020.3.x and above; author: Konrad Wojtycza

 

Introduction

Nesting business rules in the form rules allow you to refer to data contained in Active Directory or external data sources. This extends the functionality of form rules and allows you to use data outside the form when defining the process logic.

Execution of a form rule for a specific group of users

By using the business rules, you can create a condition that defines a certain group of users for which the form rule should be executed. By using the function in the “Users” section, you can enter a list of users or groups from Active Directory or defined BPS groups.

Fig. 1. The business rule with the function of checking if a user belongs to a given group

 

After defining the business rule that returns TRUE or FALSE, create the form rule that will indicate the specified form fields only for the previously defined group of people. In the form rule definition section, refer to the business rule by typing their name.

Fig. 2. Form rule with the nested “ User is from secretary” business rule

 

You can also use the panel of the right. A list of defined business rules in the process will appear in the Functions tab. This rule is added by using the drag and drop method or by double clicking the mouse. The created form rule is presented in Fig. 3.

Fig. 3. The full definition of the form rule with using the business rule

 

Execution of a form rule depending on data in other instances/workflows

In the business rules, there is the ability of referring to the SQL database and returning the specified data based on the process configuration or documents registered in the system. In the example, the SQL COMMAND function was used and it was checked whether contracts of a specified type already exist for a given vendor (Fig. 4). If so, the user will be able to follow the path that will load data from one of the table.

Fig. 4. The business rule that uses the SQL COMMAND function

 

The business rule defined in this way can be used in the definition of a form rule condition, by means of which the path enabling data initialization will be hidden and displayed (Fig. 5).

Fig. 5. The form rule hiding/displaying the path allows for data initialization

 

Setting a modified field value from an existing document

In the choice field configuration (Autocomplete and Pop-up search window) there is the ability of transferring values from the data source columns to the fields indicated on the form. The limitation of this solution is the ability of transferring only the exact data that is in the source. If you want to modify data to be transferred, use the SQL query which is defined in the business rule (Fig. 6).

Fig. 6. The businesss rule that returns date a year later than the “Start date” of the last contract

 

Data returned in the business rule can be used in a form rule by setting a value for a specific field. If this rule is executed on the change of the value of the “Previous agreement” field, then the date on the “Start date” field will be entered one year later than on the document indicated in the choice field.

Fig. 7. The form rule using the business rule from Fig. 6

 

If the different values are transferred to the different form fields, it will be necessary to define the separate rules for each field.

Using an external data source

This part describes how to use an external data source in the form of an ERP database to retrieve supplier data.

Fig. 8. The configured connection to an external MSSQL database

 

Connections to the external database are configured in the “Data source -> Connections” tab. In the presented example, the connection is defined to the MSSQL database (Fig. 8).

After configuring the connection to the database, you can also add the SQL data source with a query that selects data from the selected table. In the indicated example there is the provider’s data from the Suppliers table (Fig. 9).

Fig. 9. The data source selecting data from the Suppliers table

 

The prepared data source can be used to download the supplier’s data on the form based on their name (the Supplier name field) or VAT ID (the Supplier VAT ID field). The supplier’s data will be displayed on the form in the Name, VAT ID , City and Address fields after going through the “Download Supplier data” path (Fig. 10).

Fig. 10. The form prepared to download the supplier’s data

 

On the “Download Supplier data” an action of changing many field values has been defined. Thanks to using a data filter from the data source, are selected only suppliers for who the value entered in the Supplier name or Supplier VAT ID fields is equal to the Sup_Name or Sup_VATID column value from the Suppliers tab in the ERP database. Form field mapping is available in the Fields mapping section (Fig. 11).

Fig. 11. The configuration of the “Changes values of multiple fields” action

 

Such prepared configuration allows you to download supplier’s data corresponding to the “Supplier name” or “Supplier VAT ID” field values from the ERP database, after selecting the “Download Supplier data” path (Fig. 12).

Fig. 12. The form with supplier’s data downloaded

 

Form rule performance with the nested business rules

When creating a form that uses the business rule (that returns the query result of a database query), you should take into account the correctness and speed of execution of the query defined in the SQL COMMAND function. In the case of unoptimized queries against large tables, you risk a slowdown in the loading speed of the form if the rule is executed when it is loading. In the case of form rules with nested business rules on a field value change, an unoptimized query will be run after each value change, which can significantly degrade the performance of the form and even cause the form to crash and lose data.

Summary

Using the business rules in the form rules can be used when you need to include data outside the form. However, remember to use external data sources only when it is necessary and when using this kind of source you need to be sure to optimize the functions contained in the business rules so as not to reduce the performance of the form.

Leave a Reply

Your email address will not be published. Required fields are marked *