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).


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;

Next page: Event sequence for writing data from information register record forms (save and close)
Be the first to know tips & tricks on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.