Using script tools for working with applied objects





Working with applied objects (configuration objects) is similar to working with other objects, as both processes have certain principles in common. By understanding these principles you can quickly learn to manage all applied objects, whether they are catalogs, charts of accounts, documents, registers, or any other applied objects.

This section is a theoretical one, but in order to successfully develop with 1C:Enterprise you need to understand how objects are classified. The following table lists the types of 1C:Enterprise script objects with practical examples, a brief description of each type, their typical properties and methods (those that are common for different objects):

Object type Description Typical
properties and methods
Manager of applied objects of specific type

Examples:

  • CatalogsManager
  • DocumentsManager
  • ConstantsManager
  • AccumulationRegistersManager
  • ReportsManager
  • DataProcessorsManager

An object of this type provide access to the managers of a specific applied object.

Usually such objects are accessed via global context properties, for example, Catalogs.Employees, Documents.Account, InformationRegisters.CurrencyRates, and so on.

These objects are collections of values that can be used to iterate through their elements using the For Each loop.

Properties correspond to the names of applied objects and are themselves objects of "applied object manager" type.

Applied object manager

Examples:

  • CatalogManager
  • DocumentManager
  • ConstantManager
  • AccumulationRegisterManager
  • ReportManager
  • DataProcessorManager

This is the central object of the object model that you can use to obtain any other objects, such as references, selections, objects to be changed, record sets, and so on (see section "Object interconnection" later in this article).

An object of this type provides access to an applied object as a set of items. Methods of this object can be used to search for data, obtain selections, create new records, or call forms and templates of the applied object.

Typical properties (for catalogs and charts):
  • <name of a predefined item>
Typical methods:
  • Select()
  • FindByCode()
  • FindByAttribute()
  • EmptyRef()
  • CreateItem()
  • CreateRecordSet()
  • GetTemplate()
  • GetForm()
Ref

Examples:

  • CatalogRef
  • DocumentRef
  • ChartOfAccountsRef
  • ChartOfCalculationTypesRef

This object unambiguously identifies a database object (for example, a catalog item or a document) and can be used to access the object in read-only mode. You can use properties and methods of this object for reading the attributes of an item or accessing its tabular sections.

References are stored in the attributes referencing the items of the applied object. For example, the Employee attribute of the Recruitment document stores the reference to the particular item of the Employees catalog.

Note that register records have no references.

To change a database object (such as a catalog item or a document) you have to obtain the object itself using the GetObject() method.

Typical properties:
  • <attribute>
  • <tabular section>
  • DeletionMark
  • Date
  • Predefined
  • Ref
Typical methods:
  • IsEmpty()
  • GetObject()
  • GetForm()
  • Metadata()
  • Copy()
Selection

Examples:

  • CatalogSelection
  • DocumentSelection
  • DocumentJournalSelection
  • AccumulationRegisterSelection

You can use this object to iterate through database objects. For example, you can iterate through catalog items or through documents within a journal.

Note that this object is not a collection of values, so you cannot iterate through its elements using the For Each loop.

The properties are similar to properties of objects of the Ref type.

Typical methods:

  • Next()
  • GetObject()
Object

Examples:

  • CatalogObject
  • DocumentObject
  • ChartOfAccountsObject
  • ReportObject
  • DataProcessorObject

Provides access to an item with the option to write the changes to the  database. This object has methods that can change the item in the database, such as Write and Delete.

This object is basically used for generating reports or running data processors.

If an applied object module (do not confuse it with the form module) has some exported module variables or procedures or functions, these are added to the properties and methods of this very object.

There is no such object for registers. The changes of register data are always done through a set of records (see later in this article).

The properties are similar to properties of objects of the Ref type.

Typical methods:

  • Write()
  • Delete()
  • Lock()
  • Unlock()
  • IsLocked()
  • Copy()
  • GetForm()
  • GetTemplate()
  • Metadata()
List

Examples:

  • CatalogList
  • DocumentList
  • DocumentJournalList
  • ChartOfAccountsList
  • AccumulationRegisterList
  • FilterCriterionList

This object is used to manage a list of items in a table field. It can be used for managing columns, as well as for filtering and sorting list items.

This object cannot be created using 1C:Enterprise script, instead it is created automatically when you add a table field to a form. Of course, you can create a table field in a screen form using 1C:Enteprise script, and then an object of this type is created automatically.

Typical properties:
  • Columns
  • Filter
  • Order
Typical methods:
  • Refresh()
Record set

Examples:

  • InformationRegisterRecordSet
  • AccumulationRegisterRecordSet
  • AccountingRegisterRecordSet
  • CalculationRegisterRecordSet
  • SequenceRecordSet

A record set can be used to handle several records of an applied object (usually, a register) at the same time. You can read an entire record set from a database, then add some new records to it or change the existing ones and then write the record set to a database (in a single transaction).

Documents have Records property, which is a collection. It provides access to record sets of each register selected in the Register records tab. Document register records are usually created via this property when the document is posted.

Typical properties:
  • Filter
  • ThisObject
Typical methods:
  • Add()
  • Delete()
  • Clear()
  • Write()
  • Read()
  • Count()
  • Unload()
  • Load()
Record

Examples:

  • InformationRegisterRecord
  • AccumulationRegisterRecord
  • AccountingRegisterRecord
  • CalculationRegisterRecord

This object provides access to a single record of a record set in order to define its dimensions, resources, and so on. This object is returned by methods of other objects, for example, by the Add method of the AccumulationRegisterRecordSet object.

An object of the Record type is not a constant identifier for a specific register record (unlike the Ref object for catalogs and documents). Information register records have no identifiers that never change in time; each register record is defined unambiguously by the values of its dimensions (including system ones, such as Period, Recorder, and LineNumber).

Typical properties:
  • <dimension>
  • <attribute>
  • <resource>
  • Active
  • Period
  • Recorder
  • LineNumber
  • RecordType
Typical methods:
  • PointInTime()
Record key

Examples:

  • InformationRegisterRecordKey
  • AccumulationRegisterRecordKey
  • AccountingRegisterRecordKey
  • CalculationRegisterRecordKey

This object is required to identify a register record in a table field (for example, in a record set of a recorder document, or in a list of all register records). It is used for positioning at a particular register record of a list of records.

Typical properties (except the information register):
  • LineNumber
  • Recorder

Information register properties:

  • <Dimension name>
  • Period
  • Recorder

Specific objects

Some of the important objects that do not fit into the classification above are:

Object type Matching 
applied object
Description

Information register record manager

Information registers

This object is used to perform operations on a single record of an information register. Only independent information registers (the ones that are not subordinate to a recorder) can have this object.

Note that even if records are edited using a record manager, a register record set is still used at the lower layer: when records are saved or deleted, the events of the register record set module are triggered.

ChartOfAccountsExtDimensionTypes
ChartOfAccountsExtDimensionTypesRow

Charts of accounts This object is used for working with a list of external dimension types attached to an account.

AccountingRegisterExtDimensions

Accounting registers The ExtDimensions property of the AccountingRegisterRecord object is an object of this type. This object is a collection of values and can be used to manage external dimension values for a particular accounting register record.

ConstantsSet

Constants

This object is similar to RecordSet objects in the way that it allows reading/writing values of multiple constants from/to a database in a single transaction. The set of its properties and methods is not similar to that of record sets, and that is why it is put among other specific objects.

ExternalDataProcessorsManager
ExternalDataProcessor

External data processors

External data processors manager is similar to the managers of other applied objects. Its Create(<file name>) method can be used to create an object of ExternalDataProcessor type. This object is in turn similar to the objects of ReportObject and DataProcessorObject types. It provides access to attributes and tabular sections of the external data processor for data processing or for passing report generation parameters.

If an external data processor module (not to be confused with the form module) contains exported module variables or procedures or functions, they are added to the set of properties and methods of the ExternalDataProcessor object.


Object interconnection

Below is a description of interconnections between 1C:Enteprise objects, which are typical for objects with references (catalogs are used as an example).

NOTE: The diagram does not show all the objects and interconnections possible. For instance, the Copy() method can belong to both the CatalogRef and the CatalogObject objects. In addition, the CatalogManager object has FindByDescription() and FindByAttribute() methods that are similar to the FindByCode() method and return a reference to an item or an empty reference if the item is not found. The diagrams do not also show any specific objects or objects of List type.

And now let us proceed to another interconnection that is common for registers (accumulation registers are used as an example):

As you can see, the left parts of these diagrams are very much alike, while the right ones are different. You should not think that the RecordKey object is similar to Ref objects, or that RecordSet and Record objects are similar to Object objects, even though there is some resemblance between them.

  • The RecordKey object resembles the Ref object in that it is the most accurate identifier of a specific register record possible (it is not as absolute as the Ref object, though). You should always remember that particular register records have no references, in other words, there are no unique identifiers that would differentiate one record from another and make it unchangeable in time and space.
  • A RecordSet object and a Record object resemble the Object object only by the fact that data in a database is changed via these objects.

Summary

  • Working with any applied object has a great deal in common with working with other applied objects, as it is organized using several 1C:Script objects each of which has its own purpose and a typical set of properties and methods. However, an applied object’s set of properties and methods may vary from the typical one.
  • You can use certain properties and methods to obtain various 1C:Enterprise objects from other 1C:Enterprise objects.
  • Two groups of applied objects can be distinguished: those that contain references (catalog items, catalogs, and documents) and those that do not contain them (usually related to registers).
  • Some 1C:Enterprise objects do not fit into the general pattern and are described separately.

Comments
0
Add comment