Autocomplete Rules
Depending on your needs and business processes, you can create rules for autocompletion of Reference type fields in records of tables belonging to any application. The system allows you to make a selection of possible values for autocompletion as well as set its logic:
- The Custom autocomplete type allows you to create a script for the value selection among records included in the secondary selection. Alternatively, you can specify a single record to be used as the autocomplete value.
- The Load balancer autocomplete type makes the system choose one record from those included in the secondary selection that is least frequently used as a value in the autocomplete table records.
- If you use the Round robin autocomplete type, the records included in the secondary selection will be used as values in turns, one after another.
Roles required:
- Create, edit, delete – crm_admin, admin.
- Read – any user of the agent interface.
Create an autocomplete rule
Autocompletion occurs only when a new record is being created. No other events trigger the autocompletion of fields in a record according to a given rule.
To create an autocomplete rule, follow the steps below:
-
Navigate to CRM → Settings → Autocomplete Rules.
-
Click New and fill in the form fields.
-
Click Save or Save and exit to apply the changes. A record containing and enabling the autocomplete logic will automatically be added to the Business Rule (sys_business_rule) table.
The values of the created business rule's fields
-
The Name of the created business rule is generated according to the following template: {Autocomplete rule Name} Autocomplete Business Rule.
-
Some of the business rule's fields are completed with the values from the autocomplete rule. The table below shows the correlation of such fields in the autocomplete and business rule records.
Autocomplete rule field Business rule field Description Description Inherited Inherited Active Active Table to autocomplete Table Autocomplete conditions Filter conditions -
Some of the business rule's fields are automatically completed with predefined values, the same for all such rules:
Field Value When Before Order 999 Record created Yes Advanced Yes
-
Autocomplete Rule form fields
| Field | Mandatory | Description |
|---|---|---|
| Name | Y | Specify the name of the autocomplete rule. |
| Description | N | Add a description of the autocomplete rule. |
| Active | N | Select the checkbox to activate the autocomplete rule. When the rule is active, the autocomplete is performed according to its configuration. If you deactivate the autocomplete rule, the created business rule is deactivated as well. |
| Inherited | N | Select the checkbox to apply the automatically created Business rule to the child tables of the specified Table to autocomplete. |
| Use script for autocomplete value | N | The field is displayed if the Autocomplete type is set to Custom. Select the checkbox to create the value selection logic with a script for the records included in the secondary selection. |
| Use script to narrow selection | N | The field is displayed if the Autocomplete type is set to Custom and the Use script for autocomplete value checkbox is selected. Select the checkbox to create a script narrowing the pool of possible autocomplete values after the secondary selection's condition is applied. |
| Business rule | N | The field is completed automatically after saving the record and refers to the automatically created business rule that implements the autocomplete logic. You can manage this business rule in System Settings → Business Rules. |
| Initial selection table | Y | Specify a table with a field referencing the possible autocomplete values' table. If you change the value of the current field, the Secondary selection field field will be cleared. |
| Initial selection conditions | N | Use the condition builder to create a condition for the Initial selection table records. For instance, if User Group is set as the Initial selection table, in the current field you can specify the group whose members can be used as autocomplete values. If you change the value of the current field, the Autocomplete value field will be cleared. |
| Secondary selection field | Y | Specify a Reference type field of the Initial selection table or its parent table. This field must refer the table of possible autocomplete values. For instance, if User Group is set as the Initial selection table, in the current field you can specify the User column to use employee profiles included in the selected group as possible autocomplete values. If you change the value of the current field, the Autocomplete value and Field to autocomplete fields will be cleared. |
| Secondary selection conditions | N | Use the condition builder to narrow the secondary selection of possible values. For instance, if User Group is specified in the Initial selection table field, and the Secondary selection field is User, the current field may contain additional criteria for the users of the group selected according to the initial selection condition. Such criteria may include, for instance, being active or belonging to a specific company. If you change the value of the current field, the Autocomplete value field will be cleared. |
| Table to autocomplete | Y | Specify the table whose records must be autocompleted with the value selected after applying the initial and secondary selections, conditions configured for them, and the execution of scripts if configured. |
| Field to autocomplete | Y | The field is displayed after you specify the Table to autocomplete. Specify a Reference type field belonging to the Table to autocomplete whose value you need to autocomplete. If you change the value of the current field, the Autocomplete value will be cleared. |
| Autocomplete conditions | N | The field is displayed after you specify the Table to autocomplete. Use the condition builder to create a condition to be applied to the records of the Table to autocomplete. This condition must be met for the autocomplete rule to apply to a record. For instance, you can allow autocompletion only for records created in specific states. |
| Autocomplete type | Y | Select the autocomplete type. Available options:
|
| Narrow selection script | Y/N | The field is mandatory and displayed if the Use script to narrow selection checkbox is selected. Create a script that will narrow the list of possible values for autocompletion after the initial and secondary selection conditions are applied. |
| Autocomplete value script | Y/N | The field is mandatory and displayed if the Use script for autocomplete value checkbox is selected. Create a script that will select the record that must be used as the Autocomplete value among the records included in the secondary selection and that met the criteria of the Narrow selection script if the latter is configured. |
| State field | Y/N | The field is mandatory and displayed if the Autocomplete type is set to Load balancer. Select a Choice type column from the specified Table to autocomplete or its parent table that contains the record's state. If you change the value of the current field, the Ignored states field will be cleared. |
| Ignored states | N | The field is displayed if the Autocomplete type is set to Load balancer. Select the states in which records of the table to autocomplete need to be ignored when calculating a value's load. |
| Current counter position | Y | The field is mandatory and displayed if the Autocomplete type is set to Round robin. Specify the current position of the autocomplete counter. A record's position depends on the creation dates of the records included in the selection: the most recently created record takes position 0. Each previously created record has a position higher by 1. At the initial launch of the autocomplete rule, the calculation starts with position 1, which corresponds to the second to latest created record. If you create a new record that will be included in the selection, the positions of the previous records will shift by 1, and some might be used as the value again. Such situation may also occur if an older record is modified and gets included in the selection: it will be added to the possible values pool depending on its creation date, shifting the positions of the earlier created records by 1. |
| Autocomplete value | Y/N | The field is mandatory and displayed if all of the following conditions are met:
|
Each time an autocomplete rule is triggered, you will see an informational toast message about it on the autocompleted record's form.
-
There can be only one autocomplete rule configured for each column of a specific table. If you create a new rule for the same column, the older rule automatically deactivates.
-
If applying configured selection results in zero possible values, the autocomplete will not happen. You will see a corresponding message on the form of the record that was supposed to be autocompleted.
-
Changing the values in the following fields of an autocomplete rule updates the created business rule:
- Name
- Description
- Table to autocomplete
- Field to autocomplete
- Autocomplete conditions
- Active
- Inherited
Changing values in the other fields of an autocomplete rule will not update the related business rule.
-
The system uses the logic validating an employee's presence if all of the following conditions are met:
- the autocomplete value is taken from the User (user) table or its child table,
- the absence engine is configured for the table of possible values,
- according to the Absence (sys_personal_schedule_entry) table, the selected user is absent today.
When all the conditions listed above are met, different logic is used depending on the Autocomplete type:
Autocomplete type Result - Load balancer
- Round robin
- Custom without the use of the Autocomplete value script
The user whose profile is supposed to be the autocomplete value is skipped, and the next one from the pool of possible values is assigned. Custom with the use of Autocomplete value script The presence validation occurs after the secondary selection and before the logic from the script is executed. If the script logic assigns a user who is absent today to a record, autocompletion will not occur. You will see a corresponding message on the form of the record that was supposed to be autocompleted.