1C:Enterprise 8.3. Practical Developer’s Guide. Quick developer reference. Information registers

Information registers

1C:Enterprise script objects used for operations with information registers

The following chart shows the interaction between 1C:Enterprise script objects used for operations with information registers (fig. 29.16).

Quick developer reference / Information registers / 1C:Enterprise script objects used for operations with information registers
Fig. 29.16. 1C:Enterprise script objects used for operations with information registers

Note. The yellow box indicates the data manipulation object. The object method from which the arrow originates is marked with the respective number in the listing, while the target object of the arrow is the type of returned object.

Learn more! For details on major types of 1C:Enterprise script objects, see section 1C:Enterprise script objects used for operations with applied data.

InformationRegisterRecordManager.<name> is used to read, write, and delete individual information register records. It is available only for information registers that cannot be changed by recorders (those having the "Write mode" property set to Independent in Designer).

InformationRegisterRecord.<name> provides access to information register records. This object is not created directly. Instead, it is provided by other objects related to information registers. For example, this object represents register records in a record set.

InformationRegisterRecordKey.<name> is a set of values that uniquely identify a register record. This object is used for referencing a specific record. For example, this object represents a value of the CurrentRow property of the tabular section that stores a list of register records.

For examples of operations with information registers that involve 1C:Enterprise script objects, see listing 29.8.

Listing 29.8. Object usage examples

1.  // Global context
    // InformationRegisters
 
// Example: getting the current price from the Prices periodic information register.
Item = Catalogs.MaterialsAndServices.FindByCode(4);
Filter = New Structure("MaterialOrService", Item);
ResourceValues = InformationRegisters.Prices.GetLast(CurrentDate(), Filter);
Price = ResourceValue.Price;
 
2.  // InformationRegistersManager object
    // .<information register name>
    // [<information register name>]
    // For Each … In … Do … EndDo;
 
// Example: getting the initial price from the Prices periodic information register.
RegisterName = "Prices";
Service = Catalogs.MaterialsAndServices.FindByDescription("Diagnostics");
Filter = New Structure;
Filter.Insert("MaterialOrService", Service);
Price = InformationRegisters[RegisterName].GetFirst(CurrentDate(), Filter).Price;
 
3.  // InformationRegisterManager.<name> object
    // CreateRecordKey()
 
// Example: activating a row in the information register list.
KeyFieldStructure = New Structure;
KeyFieldStructure.Insert("Period", Date("20140331000000"));
KeyFieldStructure.Insert("MaterialOrService", Catalogs.MaterialsAndServices.FindByCode("0000006"));
Items.Materials.CurrentRow = InformationRegisters.Prices.CreateRecordKey(KeyFieldStructure);
 
4.  // InformationRegisterManager.<name> object
    // CreateRecordSet()
 
// Example: displaying materials and services whose price was set at the given date and time.
Set = InformationRegisters.Prices.CreateRecordSet();
Set.Filter.Period.Set(SpecifiedDate, True);
Set.Read();
For Each NextRecord In Set Do
    Message("Material or service = " + NextRecord.MaterialOrService + ", price = "
        + NextRecord.Price + ".");
EndDo;
 
5.  // InformationRegisterManager.<name> object
    // CreateRecordManager()
 
// Example: adding a price value to the Prices register.
Record = InformationRegisters.Prices.CreateRecordManager();
Record.Period = CurrentDate();
Record.MaterialOrService = Catalogs.MaterialsAndServices.FindByCode(?0000005?);
Record.Price = 568;
Record.Write();
 
6.  // InformationRegisterRecordSet.<name> object
    // [<collection element index>]
    // For Each … In … Do … EndDo;
 
// Example: displaying materials and services whose price was set at the given date and time.
Set = InformationRegisters.Prices.CreateRecordSet();
Set.Filter.Period.Set(SpecifiedDate, True);
Set.Read();
For Each NextRecord In Set Do
   Message("Material or service = " + NextRecord.MaterialOrService + ", price = "
       + NextRecord.Price + ".");
EndDo;
 
7.  // InformationRegisterSelection.<name> object
    // GetRecordManager()
 
// Example: Deleting all information register records for the current month.
Selection = InformationRegisters.Prices.Select(BegOfMonth(CurrentDate()),
    EndOfMonth(CurrentDate()));
While Selection.Next() Do
    Selection.GetRecordManager().Delete();
EndDo;
 
8.  // InformationRegisterManager.<name> object
    // Select()
    // SelectByRecorder()
 
// Example: displaying price changes for a material or service over the course of a year.
Filter = New Structure(?MaterialOrService?, Catalogs.MaterialsAndServices.FindByCode(?0000005?));
Selection = InformationRegisters.Prices.Select(BegOfYear(CurrentDate()), CurrentDate(), Filter);
While Selection.Next() Do
    Message("Date = " + Selection.Period + ", price = " + Selection.Cost + ".");
EndDo;

Event sequence for writing data from information register record forms (save and close)

Quick developer reference / Information registers / Event sequence for writing data from information register record forms (save and close)
Fig. 29.17. Event sequence for writing data from an information register record form

Note. Yellow boxes indicate events executed in the writing transaction.

Information register record forms are accessed using the InformationRegisterRecordManager.<name> object, which in turn uses the InformationRegisterRecordSet.<name> object.

The internal implementation of the InformationRegisterRecordManager.<name> object defines that when an existing information register record is being written the BeforeWrite() and OnWrite() event handlers from the record set module are called twice: first they are called for the "old" record set (with a record count of 0), and then for the "new" record set (with a record count of 1).

Event sequence for writing data from information register record set forms (save and close)

Quick developer reference / Information registers / Event sequence for writing data from information register record set forms (save and close)
Fig. 29.18. Event sequence for writing data from an information register record set form

Note. Yellow boxes indicate events executed in the writing transaction.

Leave a Reply

Your email address will not be published. Required fields are marked *

1C:Enterprise Developer's Community