Accounting by customers option
Note that functional options can affect not only the applied solution command interface but also the appearance of applied solution forms. Besides, functionality can be enabled or disabled without restarting the client application. You can also work with functional options using 1C:Enterprise script. With all that, the functional options feature makes deployment and customization simple and straightforward even for beginner users.
Now let us look into another example.
Some companies do not need to record customer names. Often only the fact that a service is rendered matters while the personality of a customer does not.
So let us implement the option to disable maintenance of a customer list to prevent users from having to specify the customer every time a service is rendered.
Let us also update existing functional options by including the Accounting and Payroll subsystems in these options. This is needed for the solution to look complete: if accounting is not needed, it should not be present anywhere.
In Designer mode
First, let us add subsystems to the functional options.
- Open Accounting functional option content and add the Accounting subsystem.
- Open Payroll functional option content and add the Payroll subsystem (fig. 25.11).
Fig. 25. 11. Payroll functional option content
Now let us proceed to creating a new functional option. You need a constant to store the option value.
- Add a constant named AccountingByCustomers of Boolean type (fig. 25.12).
Fig. 25.12. AccountingByCustomers constant
- Add a functional option named AccountingByCustomers and specify that its value is stored in the AccountingByCustomers constant (fig. 25.13).
Fig. 25.13. AccountingByCustomers functional option
- On the Content tab, specify the objects to be included in the functional option (fig. 25.14):
- Customers catalog
- Customer attribute of the Services document
- Customer dimension of the Sales accumulation register
Fig. 25.14. AccountingByCustomers functional option content
Let us update the GeneralSettings common form that is used to specify functional option values.
- In the GeneralSettings form editor, drag the AccountingByCustomers constant to the form controls (fig. 25.15).
Fig. 25.15. GeneralSettings form
Next you have to ensure that the applied solution interface is refreshed when new functional option values are applied.
- In the form controls tree, double-click the root Form item.
- In the property palette, find the After write at client event and click the Open button in that field.
- Specify that the handler is only executed on the client.
- In the form module that is opened, add a single line to the handler body, as shown in listing 25.1.
Listing 25.1. AfterWrite form event handler
&AtClientRefreshInterface() is a global context method that refreshes the command interface, the start page, and opened forms according to the current functional option values and their parameters.
To simplify testing the functional options, let us modify the common form so that it does not block the main applied solution window.
Currently, when you open the GeneralSettings form in 1C:Enterprise mode, you cannot change anything in the main applied solution window because it is blocked while the General Settings form is open. This happens because the form wizard selected the default Lock parent window value for the Window open mode property.
- Click the Form tab and then, in the form controls tree, double-click the root Form item.
- In the property palette, set Window open mode to Independent (fig. 25.16).
Fig. 25.16. Window open mode property
In 1C:Enterprise mode
Let us test the changes.
- Start 1C:Enterprise in the debug mode.
- In the Quick menu section, click General settings.
You can see that the Accounting by customers option is disabled (fig. 25.17).
Fig. 25.17. Accounting by customers functional option is disabled
Let us check how this affects the Services document.
- In the Services section, click Services and open any of the documents, for example, Services #2 (fig. 25.18).
Fig. 25.18. Services document
The document does not have the Customer field, and if you switch to the list of Sales register records using the navigation panel command, you can see that it no longer has the Customer column. Also, the Customers command is absent from the Enterprise section.
- Return to the General settings form, select the Accounting by customer check box, and click Save.
This introduces some changes to the applied solution interface. Return to the Services #2 document (fig. 25.19).
Fig. 25.19. Services document
The document has the Customer field, the list of register records has the Customer column, and the Customers command is again available in the Enterprise section.
- In the General settings form, enable all functional options and click Save (fig. 25.20).
Fig. 25.20. General settings
This enables all of the applied solution features. Note that the applied solution interface is refreshed immediately once you save the settings.
This completes the configuration development.
The next two lessons are devoted to standard 1C:Enterprise development techniques. For some examples we will provide multiple implementation options, so it is up to you to decide which one to choose.