These recommendations apply to 1C:Enterprise version 8.3.3 or later (except configurations where compatibility mode is set to Version 8.2 or earlier). They are mandatory unless noted otherwise.
1.1. You have the option to create predefined items in catalogs, charts of accounts, and charts of calculation types, both automatically or using 1C:Enterprise script.
1.2. In most scenarios we recommend that you have predefined items created automatically because they are needed at all times and because this simplifies calling them from 1C:Enterprise script. Examples of such scenarios are the predefined USA item in the Countries catalog and the predefined Administrator access group profile.
For the automatic creation, do the following:
- Set the value of the PredefinedDataUpdate catalog, chart of accounts, or chart of calculation types property to Auto (the default value) and ensure that you never call the SetPredefinedDataUpdate method for those objects (this method sets the property value).
- Ensure that users cannot delete predefined items by disabling the following rights for all users (these rights are disabled by default):
- Interactive deletion of predefined objects
- Interactive deletion mark on predefined objects
- Interactive removal of deletion mark from predefined objects
- Interactive deletion of marked predefined objects
1.3. Subordinate nodes of distributed Infobases are exceptions to this rule. In such nodes predefined items must not be created or updated automatically. Instead, they must be replicated from the master node together with the configuration changes.
In this case ensure the following:
a) The configuration loads an exchange message to a subordinate node prior to the execution of the script that accesses predefined items retrieved from the master node.
b) The applied logic of loading data from the master node (for example, the OnReceiveDataFromMaster handler and object registration rules) does not include accessing predefined items because you cannot be sure that they have already been loaded from the exchange message.
c) The Infobase update handler script that processes predefined items is not executed in subordinate Infobase nodes:
If ExchangePlans.MasterNode() = Undefined Then
// fill predefined items
// ...
EndIf;
1.4. We recommend that for tables with predefined items that are not included in the distributed Infobase exchange plan (and are not referenced by other tables included in the exchange plan) you set the PredefinedDataUpdate property to AutoUpdate.
If you use the compatibility mode with version 8.3.3, on the first start of a subordinate node (right after its configuration update) set automatic data update using the following script:
Catalogs.<CatalogName>.SetPredefinedDataUpdate(PredefinedDataUpdate.AutoUpdate);
2. In some cases automatic creation of predefined items is not required. This includes cases when the availability of predefined items depends on some condition (functional option values, application mode, and so on).
For example, the availability of predefined items in the Accruals chart of calculation types can depend on the values of the following functional options: UseHourlyWorkTimeRecords, UsePieceworkWages, and so on.
If this is the case, do the following:
- Set the PredefinedDataUpdate property of a catalog, chart of accounts, or chart of characteristic types to Do not update automatically.
- Write the script that creates predefined items depending on the business logic (and marks them inactive), for example:
If GetFunctionalOption("UseHourlyWorkTimeRecords") Then
AccrualObject = ChartsOfCalculationTypes.Accruals.CreateCalculationType();
AccrualObject.PredefinedDataName = "HourlyPayment";
// ...
AccrualObject.Write();
EndIf;
- When writing script algorithms, take into account that the predefined items might be not available (accessing an unavailable item throws an exception):
... = ChartOfCalculationTypes.Accruals.HourlyPayment;
... = PredefinedValue("ChartOfCalculationTypes.Accruals.HourlyPayment");