Scope: managed applications, mobile applications, and ordinary applications.
1. If you need to imply some restrictions on the Generate command, embed the conditional check in the Filling event handler of the object's or record set's module. Conditional check examples:
- For groups and charts of characteristic types, the Generate command does not differentiate catalogs from items. The command is available from the list form for both groups and items. Embed a check that prevents users from generating objects from groups.
- Embed a check that prevents users from generating objects from unposted documents.
2. In the Filling handler, to provide users with the failure notifications, embed exceptions. Example:
Procedure Filling(FillingData, FillingText, StandardProcessing)
If TypeOf(FillingData) = Type("CatalogRef.Employees") Then
If GetAttributeValue(FillingData, "IsFolder") = True Then
Raise "Cannot generate hiring orders from employee groups.
|Select an employee. To expand the group, press Ctrl + Arrow Down.";
// Filling the object with the filling data
It is not recommended that you employ other solutions to check whether the conditions are met. In particular, do not create additional commands for object generation and do not embed conditional checks in the command handlers.
3. It is recommended that you stick to the following Filling handler structure. Some steps can be omitted:
3.1. Special filling depending on the FillingData parameter type.
FillingDataType = TypeOf(FillingData);
If FillingDataType = Type("Structure") Then
ElseIf FillingDataType = Type("DocumentRef.SalesOrder") Then
3.2. General filling with default values for the attributes that have not been filled on the previous step. First, you need to check whether the attribute is empty.
If Not ValueIsFilled(Department) Then
Department = SettingsValueCached.DefaultDepartment();
To fill attributes with the default values, it is recommended to specify these values in the Filling value property. If the StandardProcessing parameter is True and the handler did not assign any value to the attribute, the attribute will take the default value once the Filling handler is completed.
This is the best practice to reduce filling-related logic errors and improve code readability.