Manipulating object data

 


Despite the wide variety of 1C:Enterprise script objects used to process data stored in the database, only a small number of objects can be used to edit that data. We will refer to such objects as data manipulation objects.

Each data manipulation object type has a respective module in the configuration. It is referred to as an object module or a record set module, depending on the configuration object it belongs to. For a constant this module is referred to as a value manager module.

A module of a data manipulation object is always executed when a data manipulation object is created. It is also executed every time a user interactively accesses the data structure because this initiates the creation of the corresponding data manipulation object. For example, when a catalog item form is opened, the
CatalogObject.<name> object is created.

A data manipulation object module can include procedure definitions with the Export keyword, which implies that the procedures are called as methods of the corresponding data manipulation object. Here it is important not to confuse the data manipulation object with other objects that provide access to data within the data structure.

For example, if you create a procedure (listing 29.1) in the object module of the Customers catalog configuration object, in the future you will be able to call this procedure as a method of the CatalogObject.Customers object (listing 29.2).

Listing 29.1. Check() procedure in a catalog module

Procedure Check() Export
…
EndProcedure;

Listing 29.2. Calling the procedure as a method of the Customers object

Customer = Catalogs.Customers.FindByCode(1).GetObject();
Customer.Check();

However, the following script would generate an error, since the CatalogRef.Customers object does not have a Check method (listing 29.3).

Listing 29.3. The Check procedure call that generates an error

Customer = Catalogs.Customers.FindByCode(1);
Customer.Check();

The following table lists available data manipulation objects. As always, for every rule there is an exception, and there are two exceptions here as well.

Table 29.1. Objects used for data manipulation

Configuration object Data manipulation structure
in the database
Data manipulation structure
in 1C:Enterprise script
Constant Constant ConstantValueManager.<name>
(ConstantManager.<name>, ConstantsSet)
Catalog Catalog item CatalogObject.<name>
Document Document DocumentObject.<name>
Sequence Sequence record set SequenceRecordSet.<name>
ChartOfCharacteristicTypes Characteristic type ChartOfCharacteristicTypesObject.<name>
ChartOfAccounts Account ChartOfAccountsObject.<name>
ChartOfCalculationTypes Calculation type ChartOfCalculationTypesObject.<name>
InformationRegister Information register record set InformationRegisterRecordSet.<name>
(InformationRegisterRecordManager.<name>)
AccumulationRegister Accumulation register record set AccumulationRegisterRecordSet.<name>
AccountingRegister Accounting register record set AccountingRegisterRecordSet.<name>
CalculationRegister Calculation register record set CalculationRegisterRecordSet.<name>

First, there are three data manipulation objects listed for constants: ConstantValueManager.<name>,
ConstantManager.<name>, and ConstantsSet. In practice, the data stored in constants is manipulated using the ConstantValueManager.<name> object.

The other two objects (ConstantManager.<name> and ConstantsSet) are also used for editing values of constants stored in the database. However, when their Set() and Write() methods are executed, they initiate the creation of a ConstantValueManager.<name> object, which modifies the data.

When the Set() method of the ConstantManager.<name> object is executed, the value manager module of the constant is called, as well as its OnWrite() and BeforeWrite() event handlers. When the Write() method of the ConstantsSet object is executed, the value manager module and the appropriate handlers are called for each constant in the set.

Second, there are two data manipulation objects listed for information registers. In practice, the data stored in information registers is manipulated using the InformationRegisterRecordSet.<name> object.

The InformationRegisterRecordManager.<name> object is also used for manipulating information register data. But the InformationRegisterRecordManager.<name> object does not manipulate the data directly: instead it uses the InformationRegisterRecordSet.<name> object.

So, calling the InformationRegisterRecordManager.<name> object executes the record set module, along with the BeforeWrite() and OnWrite() event handlers. However, the procedures and functions that are defined in the record set module with the Export keyword are not available as methods of the
InformationRegisterRecordManager.<name> object.


Comments
0
Add comment