1C:Enterprise 8. Practical Developer’s Guide. Developer’s Quick Reference.

Developer's Quick Reference

1C:Enterprise Script Entities for Operations with Application Data

1C:Enterprise script has a set of standardized objects for access to the data stored in the database. These types can be broken down into several types based on their purposes.

Manager for information structures of a single type. Such objects include:

  • CatalogsManager,
  • DocumentsManager,
  • ReportsManager,
  • ChartOfAccountsManager,
  • etc.

Each object is a collection of values containing managers of all the information structures of this type available in the database.

For example, a manager of catalogs (CatalogsManager) is a collection of values that contains objects CatalogManager.<name>.

Every such object is intended to access the individual managers of information structures.

Manager for specific information structures. Such objects include:

  • CatalogManager.Clients,
  • CatalogManager.Products,
  • DocumentManager.ReceiptOfGoods,
  • DocumentManager.ServicesRendered,
  • etc.

Every object provides tools to work with a specific information structure. For example, the manager of the ReceiptOfGoods document (DocumentManager.ReceiptOfGoods) is intended to find specific documents of the ReceiptOfGoods type, create objects of such documents, etc.

Object. Such objects include:

  • CatalogObject.Clients,
  • CatalogObject.Products,
  • DocumentObject.ReceiptOfGoods,
  • DocumentObject.ServicesRendered,
  • etc.

Such objects enable reading, editing, writing and deleting information structure data. They provide access to an object within an information structure and enable modifications of information in the database. They are used for information structures containing objects that support references (catalogs - CatalogObject.<name>, documents - DocumentObject.<name>, etc).

Record set. Such objects include:

  • InformationRegisterRecordSet.Prices,
  • AccumulationRegisterRecordSet.BalanceOfMaterials,
  • AccountingRegisterRecordSet.Management,
  • etc.

Such objects also enable reading, editing, writing and deleting information structure data. They provide access to an object within an information structure and enable modifications of database information. They are used for information structures containing database objects for which we generally cannot use references (registers - AccumulationRegisterRecordSet.<name>, recalculations - RecalculationRecordSet.<name>, etc).

Reference. Such objects include:

  • CatalogRef.Clients,
  • CatalogRef.Products,
  • DocumentRef.ReceiptOfGoods,
  • DocumentRef.ServicesRendered,
  • etc.

Such objects are intended to specify a link to a database object and also provide a certain amount of information about this object (e.g. a docu- ment - DocumentRef.<name>).

Selection. Such objects include:

- CatalogSelection.Clients,

- DocumentSelection.ReceiptOfGoods,

- InformationRegisterSelection.Prices,

- AccumulationRegisterSelection.BalanceOfMaterials,

- etc.

Such objects represent a data set containing data for objects of one information structure, which have been selected using a specific criterion.

The selection search is performed using the Next() method. Data is read from the database dynamically, as selection proceeds. We can obtain a reference to an object using the Reference property, while the object can be obtained using the GetObject() method (for a catalog it is CatalogSelection.<name>).

Handling Object Data

Despite the wide variety of 1C:Enterprise script entities intended to handle data in the database, only some entities enable us to edit data stored in the database. We will refer to such entities as data manipulation objects.

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

So, a data manipulation object module will always be executed when creating a data manipulation object. Besides, it will also be executed every time a user interactively accesses the data structure itself, since such an action will call for creation of the corresponding data manipulation object. For example, when a catalog item form is opened, the CatalogObject.<name> object will be created.

Within the data manipulation object module, in addition to the features above, we can define procedures that use the keyword Export, which implies that these procedures will be called as methods belonging to the corresponding data manipulation object. Here it is important not to confuse the data manipulation object with other objects that provide access to the data from the same information structure.

For example, if we create a procedure in the object module (listing 28.1) for the Clients Catalog configuration object, in the future we will be able to call for this procedure as a method of the object CatalogObject.Clients (listing 28.2).

Listing 28.1. Check() procedure in a catalog module

Procedure Check() Export
	...
EndProcedure;

Listing 28.2. Calling the procedure as a method of catalog object

Client = Catalogs.Clients.FindByCode(1).GetObject();
Client.Check();

However, the following code would generate an error, since the CatalogRef. Clients object does not have a Check method (listing 28.3).

Listing 28.3. Calling the Check procedure will result in an error

Client = Catalogs.Clients.FindByCode(1);
Client.Check();

The following table contains a list of objects that can be used to manipulate data. As always, for every rule there is an exception, and there are two exceptions here as well.

Table 4.1. Operations on object data

Configuration Object

Database - data manipulation structure

1C:Enterprise script - data manipulation structure

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> (InformationRegisterRecords

Manager.<Name>)

AccumulationRegister

Accumulation register record set

AccumulationRegisterRecordSet.

<Name>

AccountingRegister

Accounting register record set

AccountingRegisterRecordSet.

<Name>

CalculationRegister

Calculation register record set

CalculationRegisterRecordSet.

<Name>

First of all, for constants there are three data manipulation objects listed - ConstantValueManager.<name>, ConstantManager.<name>, and

ConstantsSet. In practice, the data for constants is manipulated using the ConstantValueManager.<name> object.

The other two objects - ConstantManager.<name> and ConstantsSet - also modify the value of constants stored in the database. However, when their Set() and Write() methods are executed, they call for the creation of a ConstantValueManager.<name> object, which then directly modifies the data.

When executing the Set() method for the ConstantManager.<name> object, the value manager module and the OnWrite() and BeforeWrite() event handlers for the constant being changed will be called for. When executing the Write() method for the ConstantsSet object, the value manager module and corresponding handlers will be called for each constant in the set.

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

However, it is also possible to manipulate records in an information register using the object InformationRegisterManager.<name> object as well. But the InformationRegisterRecordManager.<name> object does not handle the data directly: instead it uses the InformationRegisterRecordSet.<name> object. This way, the record set module, along with the BeforeWrite() and OnWrite() event handlers, will be activated when manipulating the InformationRegisterRecordManager.<name> object, too. However, the procedures and functions that are defined in the record set module using the key word Export, will not be available as methods for the InformationRegisterRecordManager.<name> object.

Constants

1C:Enterprise Script Entities for Operations on Constants

The following chart demonstrates interaction between 1C:Enterprise script entities and the constants (fig. 28.1).

1C:Enterprise 8. Practical Developer's Guide. Developer's Quick Reference

Fig. 28.1. 1C:Enterprise script entities for operations on constants

NOTE

Filled boxes indicate data manipulation objects. The object method that serves as a source of the arrow is marked in a listing with respective number while the target object of the arrow is the type of returned method.

LEARN MORE!

For details on major types of 1C:Enterprise script entities, see "1C:Enterprise Script Entities for Operations with Application Data".

ConstantsSet - lets you perform read and write operations all at once for a group of constants, or in some cases for all the constants. It is also used in constant forms to store, write and read constants.

ConstantValueManager.<name> - used for access to constants. Any time a constant is written (interactively in a form, or as a ConstantsSet or ConstantManager.<name> object), it creates an object of that type, which is used to call the module and event handlers for that object.

Below you will find examples of how 1C:Enterprise script entities are used to operate constants (listing 28.4).

Listing 28.4. Sample uses of objects

(1)	// Global context
	// Constants
	// Example: Set constant value
	
Constants.Bookkeeper .Set("Patrick Henry Brewster");

(2)	// ConstantsManager object
	// .<constant name>
	// [<constant name>]
	// For Each ... In ... Do ... EndDo;
	
// Example: Read constant value.	
Result = Constants.NumberingPrefix.Get();
Message("NumberingPrefix constant value = "+ Result);

// Example: Set NumberingPrefix constant value equal to CB.
Constants["NumberingPrefix"].Set("CB");
Message("New value = " + Constants["NumberingPrefix"].Get());

// Example: Clear values of all constants.
For Each NextConstant In Constants Do
	NextConstant.Set(Undefined);
EndDo;

(3)	// ConstantsManager object
	// CreateSet()
	
// Example: Set new values for several constants.
Set = Constants.CreateSet("Director, Bookkeeper");
Set.Director = "Thaddeus Addison";
Set.Bookkeeper = "Alexandra Swain";
Set.Write();

(4)	// ConstantsManager.<name> object
	// CreateValueManager()
	
// Example: Output values of all constants that exist in the configuration.
For Each NextConstant In Constants Do
	ConstName = NextConstant.CreateValueManager().Metadata().Name;
	ConstValue = NextConstant.Get();
	Message("Constant "+ ConstName +" = "+ ConstValue);
EndDo;

Sequence of Events for Writing Constants from Constants Forms (Save and Close)

1C:Enterprise 8. Practical Developer's Guide. Developer's Quick Reference

Fig. 28.2. Sequence of events for writing constants from constants form

NOTE

Filled events are those execute in the writing transaction.

Constant forms are handled using the ConstantsSet object, which in its turn uses the ConstantValueManager.<name> object.

The internal implementation of the ConstantsSet object is such that, when writing the constant set, the FillCheckProcessing(), BeforeWrite() and OnWrite() event handlers from the constant value manager module will be called for each constant that goes into the set that is being written.

Catalogs

1C:Enterprise Script Entities for Operations on Catalogs

The following chart demonstrates interaction between 1C:Enterprise script entities and the catalogs (fig. 28.3).

1C:Enterprise 8. Practical Developer's Guide. Developer's Quick Reference

Fig. 28.3. 1C:Enterprise script Entities for operations on catalogs

NOTE

Filled boxes indicate data manipulation objects. The object method that serves as a source of the arrow is marked in a listing with respective number (for example, under 3 you see the FindByCode() method of the object CatalogManager.<name>), while the target object of the arrow is the type of returned method (e.g. CatalogRef.<name>).

LEARN MORE!

For details on major types of 1C:Enterprise script entities, see "1C:Enterprise

Script Entities for Operations with Application Data".

Below you will find examples of how 1C:Enterprise script entities are used to operate catalogs (listing 28.5).

Listing 28.5. Sample uses of objects

(1)	// Global context
	// Catalogs
	
// Example: Output all types of references to catalog items, that exist in the configuration.
Array = Catalogs.AllRefsType().Types();
For Each NextType from Array Do
	Message(NextType);
EndDo;

(2)	// CatalogsManager object
	// .<catalog name>
	// [<catalog name>]
	// For Each ... In ... Do ... EndDo;
	
// Example: Create new folder in Products catalog.
NewFolder = Catalogs.Products.CreateFolder();
NewFolder.Description = "My new folder";
NewFolder.Write();

// Example: Get a reference to the Products catalog.
Catalogs["Products"].GetRef();

(3)	// CatalogsManager.<Catalog name> object
	// FindByCode ()
	// FindByDescription ()
	// FindByAttribute ()
	// EmptyRef ()
	// GetRef()
	// .<name of predefined catalog item>
	
// Example: Check whether or not an element in the Products catalog is marked for deletion with code 13.
If Catalogs.Nomenclature.FindByCode(13).DeletionMark Then
	Message("The element with code 13 is marked for deletion ");
EndIf;

// Example:Is the Products catalog item named "Services" a folder.
If Catalogs.Nomenclature.FindByDescription("Services", True).IsFolder Then
	Message("The element named 'Services' is a folder");
EndIf;

// Example: Check to be sure all items have been assigned a product type.
EmptyEnumRef = Enums.ProductTypes.EmptyRef();
If Not Catalogs.Nomenclature.FindByAttribute("ProductType", EmptyEnumRef).IsEmpty() Then
	Message("Items without assigned product type were found ");
EndIf;

// Example: Pass an empty reference in the method’s parameters.
Selection = Catalogs.Products.Select(Catalogs.Nomenclature.EmptyRef());

(4)	// CatalogManager.<Catalog name> object
	// Select()
	// SelectHierarchically()
	
// Example: Output a list of the elements located at the catalog root.
Selection = Catalogs.Nomenclature.Select(Catalogs.Nomenclature.EmptyRef());
While Selection.Next() Do
	If Not Selection.IsFolder Then
		Message(Selection);
	EndIf;
EndDo;

// Example: Delete all elements from a hierarchical catalog.
Selection = Catalogs.Products.SelectHierarchically();
While Selection.Next() Do
	Selection.Delete();
EndDo;

(5)	// CatalogManager.<Catalog name> object
	// CreateFolder()
	// CreateItem()
	
// Example: Create a new element in the Employees catalog.
NewItem	=	Catalogs.Officials.CreateItem();
NewItem.Description = "Andrew A. Smith";
// Fill the tabular section PastEmployment.
NewTableRow = NewItem. PastEmployment.Add();
NewTableRow.Organization = "NTC Corp.";
NewTableRow.StartDate = Date(2003,05,01);
NewTableRow.EndDate = Date(2003,12,31);
NewTableRow.Position = "Programmer";
NewItem.Write();

(6)	//object CatalogObject.<Catalog name>, CatalogRef.<Catalog name>
	// Owner
	// Parent
	// Ref
	
// Example: prevent changes to subordinate items
// if the PreventChanges property is set for the owner
// in the catalog item form name module
Procedure BeforeWrite(Cancel)
	If Owner.PreventChanges Then 
		Cancel = True;
	EndIf;
EndProcedure

(7)	// CatalogRef.<Catalog name>
	// GetObject()
	// CatalogSelection.<Catalog name> object
	// Copy()
	
// Example: Change catalog item name.
Item = Catalogs.Products.FindByCode(10).GetObject();
Item.Description = "My new description";
Item.Write();

// Example: Fill in catalog using test data.
Item = Catalogs.Products.CreateItem();
Item.Description = "Test item";
Item.Write();
For Z = 1 to 1000 Do
	NewItem = Item.Copy();
	NewItem.Write();
EndDo;

(8)	// CatalogSelection.<Catalog name> object
	// Ref
	
// Example: Fill in the tabular section of a ReceiptOfGoodsOfGoods
// document with all the elements from the indicated Products catalog folder.
Selection = Catalogs.Products.SelectHierarchically(TextBox1);
While Selection.Next() Do
	ProductReference = Selection.Ref;
	If ProductReference.IsFolder Then 
		Continue;
	EndIf;
	NewRow = Materials.Add();
	NewRow.Material = ProductReference;
EndDo;

(9)	// CatalogSelection.<Catalog name> object
	// GetObject()
	
// Example: mark all elements in the not hierarchical catalog for deletion
Selection = Catalogs.Clients.Select();
While Selection.Next() Do
	Selection.GetObject().SetDeletionMark(True);
EndDo;

Sequence of Events for Writing a Catalog Item from Item Form (Save and Close)

1C:Enterprise 8. Practical Developer's Guide. Developer's Quick Reference

Fig. 28.4. Sequence of events when writing catalog items from an item form

NOTE

Filled events are those executed in the writing transaction.

Documents

1C:Enterprise Script Entities for Operations on Documents

The following chart demonstrates interaction between 1C:Enterprise script entities and the documents (fig. 28.5).

1C:Enterprise 8. Practical Developer's Guide. Developer's Quick Reference

Fig. 28.5. 1C:Enterprise script entities for operations on documents

NOTE

Filled boxes indicate data manipulation objects. The object method that serves as a source of the arrow is marked in a listing with respective number while the target object of the arrow is the type of returned method.

LEARN MORE!

For details on major types of 1C:Enterprise script entities, see "1C:Enterprise Script Entities for Operations with Application Data".

Below you will find examples of how 1C:Enterprise script entities are used to operate documents (listing 28.6).

Listing 28.6. Sample uses of objects

(1)	// Global context
	// Documents
	
//	Example: output all types of references to document items that exist in the configuration.
Array = Documents.AllRefsType().Types();
For Each NextType from Array Do
	Message(NextType);
EndDo;

(2)	// DocumentsManager object
	// .<document name>
	// [<document name >]
	// For Each ... In ... Do ... EndDo;
	
// Example: Get the print template for a ServicesRendered document
Template = Documents["ServicesRendered"].GetTemplate("Print");

//	Example: Get reference to each of document, that exists in the configuration.
For Each NextDocument In Documents Do
	Ref = NextDocument.GetRef();
	...
EndDo;

(3)	// DocumentsManager.<document name>
	// FindByNumber()
	// FindByAttribute ()
	// EmptyRef ()
	
// Example: Check whether the ReceiptOfGoodsOfGoods document number 3 has
// been posted.
If Documents. ReceiptOfGoodsOfGoods.FindByNumber(3).Posted Then
	Message("Document number 3 was posted");
EndIf;

//	Example: Check whether the Warehouse attribute has been filled	
// for all ReceiptOfGoodsOfGoods documents.
WarehouseEmptyRef = Catalogs.Warehouses.EmptyRef();
If Not Documents.ReceiptOfGoodsBill.FindByAttribute("Warehouse",WarehouseEmptyRef).IsEmpty() Then
	Message("Documents found with blank Warehouse attributes");
EndIf;

(4)	// DocumentManager.<Document name> object
	// Select()
	
// Example: Select all ReceiptOfGoodsOfGoods documents for the current month.
Selection = Documents.ReceiptOfGoodsOfGoods.Select(BegOfMonth(CurrentDate()), EndOfMonth(CurrentDate()));
While Selection.Next() Do
	Message(Selection);
EndDo;

(5)	// DocumentManager.<Document name> object
	// CreateDocument()
	
// Example: Create a new ReceiptOfGoodsOfGoods document.
NewDocument = Documents. ReceiptOfGoodsOfGoods.CreateDocument();
NewDocument.Date = CurrentDate();
NewDocument.Warehouse = Catalogs.Warehouses.Main;
// Fill in the Materials tabular section
NewTableRow = NewDocument.Material.Add();
NewTableRow.Material = Catalogs.Products.FindByCode(6);
NewTableRow.Count = 10;
NewTableRow.Cost = 22,5;
NewTableRow.Sum = 225;
NewDocument.Write();

(6)	// DocumentObject .<document name> object, DocumentRef.<Document name> object
	// Ref
	
// Example: Call a procedure within an object module to check
//	whether	document	attributes	are	filled.
If Not CheckAttributesFilling(ThisObject.Ref) Then
	Message("Document attributes not filled!");
EndIf;

(7)	// DocumentRef.<Document name> object, DocumentObject .<Document name> object
	// GetObject()
	// Copy()
	
// Example: Mark the document for deletion.
OldDocument = Documents.ServicesRendered.FindByNumber(13).GetObject();
OldDocument.SetDeletionMark(True);

(8)	// DocumentSelection.<Document name> object
	// Ref
	
// Example: Generate a list of references to all ReceiptOfGoodsOfGoods documents for the current month.
DocumentList = New ValueList;
Selection = Documents.ReceiptOfGoodsOfGoods.Select(BegOfMonth(CurrentDate()), EndOfMonth(CurrentDate()));
While Selection.Next() Do
	DocumentList.Add(Selection.Ref);
EndDo;

(9)	// DocumentSelection.<Document name> object
	// GetObject()
	
// Example: Delete all ReceiptOfGoodsOfGoods documents.
Selection = Documents.ReceiptOfGoodsOfGoods.Select();
While Selection.Next() Do
	Selection.GetObject().Delete();
EndDo;

Sequence of Events When Writing Documents from a Document Form

1C:Enterprise 8. Practical Developer's Guide. Developer's Quick Reference

Fig. 28.6. Sequence of events when writing documents from a document form

NOTE

Filled events are those executed in the writing transaction.

Sequence of Events When Posting Documents from a Document Form (Post and Close)

1C:Enterprise 8. Practical Developer's Guide. Developer's Quick Reference

Fig. 28.7. Sequence of events when posting documents from a document form

NOTE

Filled events are those executed in the writing transaction.

Sequence of Events When Unposting a Document from a Document Form

1C:Enterprise 8. Practical Developer's Guide. Developer's Quick Reference

Fig. 28.8. Sequence of events when unposting a document from a document form

NOTE

Filled events are those executed in the writing transaction.

Enumerations

1C:Enterprise Script Entities for Operations on Enumerations

The following chart demonstrates interaction between 1C:Enterprise script entities and the enumerations (fig. 28.9).

1C:Enterprise 8. Practical Developer's Guide. Developer's Quick Reference

Fig. 28.9. 1C:Enterprise script entities for operations on enumerations

NOTE

Filled boxes indicate data manipulation objects. The object method that serves as a source of the arrow is marked in a listing with respective number while the target object of the arrow is the type of returned method.

LEARN MORE!

For details on major types of 1C:Enterprise script entities, see "1C:Enterprise Script Entities for Operations with Application Data".

Below you will find examples of how 1C:Enterprise script entities are used to operate enumerations (listing 28.7).

Listing 28.7. Sample uses of objects

(1)	// Global context
	// Enums
	
// Example: Get an enumeration value by index
Enums.ProductTypes.Get(0);

(2)	// EnumsManager object
	// .<enum name>
	// [<enum name>]
	// For Each ... In ... Do ... EndDo;
	
// Example: get quantity of enumeration values
Enums. ["ProductTypes"].Count();

(3)	// EnumManager.<Name> object
	// .<enum value name>
	// [<enum value name >]
	// [<collection element index>]
	// For Each ... In ... Do ... EndDo;
	// EmptyRef ()
	
// Example: Get an empty reference to an enumeration value.
...
EnumEmptyRef = Enums. ProductTypes.EmptyRef();
If CurrentProduct. ProductTypes = EnumEmptyRef Then
	// Offer to fill in the product type.
...
EndIf;
...

Chart of Characteristics Types

1C:Enterprise Script Entities for Operations on Chart of Characteristic Types

The following chart demonstrates interaction between 1C:Enterprise script entities and the chart of characteristic types (fig. 28.10).

1C:Enterprise 8. Practical Developer's Guide. Developer's Quick Reference

Fig. 28.10. 1C:Enterprise script entities for operations on chart of characteristic types

NOTE

Filled boxes indicate data manipulation objects.

LEARN MORE!

For details on major types of 1C:Enterprise script entities, see "1C:Enterprise Script Entities for Operations with Application Data".

The properties and methods of interactions between the above objects are generally similar to those of the objects intended to work with catalogs (see "1C:Enterprise Script Entities for Operations on Catalogs").

Sequence of Events for Writing a Characteristic Type from Item Form (Save and Close)

1C:Enterprise 8. Practical Developer's Guide. Developer's Quick Reference

Fig. 28.11. Sequence of events when writing chart of characteristic types from an item form

NOTE

Filled events are those executed in the writing transaction.

Chart of Accounts

1C:Enterprise Script Entities for Operations on Chart of accounts

The following chart demonstrates interaction between 1C:Enterprise script entities and the chart of accounts (fig. 28.12).

1C:Enterprise 8. Practical Developer's Guide. Developer's Quick Reference

Fig. 28.12. 1C:Enterprise Script Entities for Operations on Chart of Accounts

NOTE

Filled boxes indicate data manipulation objects.

LEARN MORE!

For details on major types of 1C:Enterprise script entities, see "1C:Enterprise Script Entities for Operations with Application Data".

ChartOfAccountsExtDimensionTypes.<name>. Intended to access the methods of the special ExtDimensionTypes table for an account in general. ChartOfAccountsExtDimensionTypesRow.<name>. A row from an account's special ExtDimensionTypes table.

The properties and methods of interactions between the above objects are generally similar to those of the objects intended to work with catalogs (see "1C:Enterprise Script Entities for Operations on Catalogs").

Sequence of Events for Writing an Account from an Account Form (Save and Close)

1C:Enterprise 8. Practical Developer's Guide. Developer's Quick Reference

Fig. 28.13. Sequence of events when writing an account from an account form

NOTE

Filled events are those executed in the writing transaction.

Chart of Calculation Types

1C:Enterprise Script Entities for Operations on Chart of Calculation Types

The following chart demonstrates interaction between 1C:Enterprise script entities and the chart of calculation types (fig. 28.14).

1C:Enterprise 8. Practical Developer's Guide. Developer's Quick Reference

Fig. 28.14. 1C:Enterprise script entities for operations on Chart of Calculation Types

NOTE

Filled boxes indicate data manipulation objects.

LEARN MORE!

For details on major types of 1C:Enterprise script entities, see "1C:Enterprise Script Entities for Operations with Application Data".

DisplacingCalculationTypes.<name>. The list of displacing calculation types is a predefined table for calculation types. This table is defined only for chart of calculation types with UsesActionPeriod property checked. It has a single column - CalculationType of type ChartOfCalculationTypesRef.<name>.

DisplacingCalculationTypesRow.<name>. A row from the predefined table of displacing calculation types.

LeadingCalculationTypes.<name>. The list of leading calculation types is a predefined table for calculation types. It has a single column - CalculationType of type ChartOfCalculationTypesRef.<name>.

LeadingCalculationTypeRow.<name>. A row from the predefined table of leading calculation types.

BaseCalculationTypes.<name>. The list of leading calculation types is a predefined table for calculation types. This tabular section (BaseCalculationTypes property) is defined only for the chart of calculation types for which the DependenceOnBase property is set to Does not depend. It has a single column - Calculation Type of type ChartOfCalculationTypesRef.<name>.

BaseCalculationTypesRow.<name>. A row from the predefined table of base calculation types.

The properties and methods of interactions between the above objects are generally similar to those of the objects intended to work with catalogs (see "1C:Enterprise Script Entities for Operations on Catalogs").

Sequence of Events for Writing a Calculation Type from Calculation Type Form (Save and Close)

1C:Enterprise 8. Practical Developer's Guide. Developer's Quick Reference

Fig. 28.15. Sequence of events when writing calculation type from a calculation type form

NOTE

Filled events are those executed in the writing transaction.

Information Registers

1C:Enterprise Script Entities for Operations on Information Registers

The following chart demonstrates interaction between 1C:Enterprise script entities and the information registers (fig. 28.16).

1C:Enterprise 8. Practical Developer's Guide. Developer's Quick Reference

Fig. 28.16. 1C:Enterprise script entities for operations on information registers

NOTE

Filled boxes indicate data manipulation objects. The object method that serves as a source of the arrow is marked in a listing with respective number while the target object of the arrow is the type of returned method.

LEARN MORE!

For details on major types of 1C:Enterprise script entities, see "1C:Enterprise Script Entities for Operations with Application Data".

InformationRegisterRecordManager.<name>. Intended to read, write and delete individual information register records. Used only for information registers that are not changed by recorders, i.e. those that have Independent write mode enabled in the Designer.

InformationRegisterRecord.<name>. Enables access to information register records. The object is not created directly, but is provided by other objects associated with the information register. For example, this object represents the register records within a record set.

InformationRegisterRecordKey.<name>. Represents a set of values that unambiguously identify register records. The object is used when you need to reference a certain record. For example, it serves as the value of the CurRow property for a table box displaying a list of register records.

Below you will find examples of how 1C:Enterprise script entities are used to operate information registers (listing 28.8).

Listing 28.8. Sample uses of objects

(1)	// Global context
	// InformationRegisters
	
// Example: Get the current price from the periodic information register named Prices.
Item = Catalogs.Products.FindByCode(4);
Filter = New Structure("Products", Item);
ResourceValues = InformationRegisters.Prices.GetLast(CurrentDate(), Filter);
Cost = ResourceValue.Cost;

(2)	// InformationRegistersManager object
	// .<information register name>
	// [<information register name >]
	// For Each ... In ... Do ... EndDo;
	
// Example: Get the starting price from the periodic information register named Prices.
RegisterName = "Prices";
Service = Catalogs.Products.FindByDescription("Diagnostics");
Filter = New Structure;
Filter.Insert("Products", Service);
Price = InformationRegisters[RegisterName].GetFirst(CurrentDate(), Filter).Price;

(3)	// InformationRegisterManager.<name> object
	// CreateRecordKey()
	
// Example: Activate the desired row in the information register list.
KeyFieldsStructure = New Structure;
KeyFieldsStructure.Insert("Period", Date("20040331000000"));
KeyFieldsStructure.Insert("Product", Catalogs.Products.FindByCode("0000006"));
Items.Materials.CurrentRow = InformationRegisters.Prices.CreateRecordKey(KeyFieldsStructure);

(4)	// InformationRegisterManager.<name> object
	// CreateRecordSet()
	
// Example: Show products for which the 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("Product = "+ NextRecord.Products +", price = "+ NextRecord.Price);
EndDo;

(5)	// InformationRegisterManager.<name> object
	//CreateRecordManager()
	
// Example: Add a new price value to the Prices register.
Record = InformationRegisters.Prices.CreateRecordManager();
Record.Period = CurrentDate();
Record.Products	=	Catalogs.Products.FindByCode("0000005");
Record.Price = 568;
Record.Write();

(6)	// InformationRegisterRecordSet.<name> object
	// [<collection element index>]
	// For Each ... In ... Do ... EndDo;
	
// Example: Show products fo which the price wast 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("Products = "+ NextRecord.Products + ", price = " + NextRecord.Price);
EndDo;

(7)	// InformationRegisterSelection.<name> object
	// GetRecordManager()
	
// Example: Delete 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: Show price changes for a products item for the over the course of a year.
Filter	= New Structure("Products", Catalogs.Products.FindByCode("0000005"));
Selection = InformationRegisters.Prices.Select(BegOfYear(CurrentDate()), CurrentDate(), Filter);
While Selection.Next() Do
	Message("Date = " + Selection.Period + ", price = " + Selection.Cost);
EndDo;

Sequence of Events for Saving Data from an Information Register Record (Save and Close)

1C:Enterprise 8. Practical Developer's Guide. Developer's Quick Reference

Fig. 28.17. Sequence of Events for Saving Data from an Information Register Record

NOTE

Filled events are those executed in the writing transaction.

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

The InformationRegisterRecordManager.<name> object is implemented internally in such a manner that when the corresponding information register record is saved, the BeforeWrite() and OnWrite() event handlers from the record set module will be 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).

Sequence of Events for Saving Data from a Record Set

Form of an Information Register (Save and Close)

1C:Enterprise 8. Practical Developer's Guide. Developer's Quick Reference

Fig. 28.18. Sequence of events for saving data from a record set form of an information register

NOTE

Filled events are those executed in the writing transaction.

Accumulation Registers

1C:Enterprise Script Entities for Operations on Accumulation Registers

The following chart demonstrates interaction between 1C:Enterprise script entities and the accumulation registers (fig. 28.19).

1C:Enterprise 8. Practical Developer's Guide. Developer's Quick Reference

Fig. 28.19. 1C:Enterprise script entities for operations on accumulation registers

NOTE

Filled boxes indicate data manipulation objects. The object method that serves as a source of the arrow is marked in a listing with respective number while the target object of the arrow is the type of returned method.

LEARN MORE!

For details on major types of 1C:Enterprise script entities, see "1C:Enterprise Script Entities for Operations with Application Data".

AccumulationRegisterRecord.<name>. Used to access accumulation register records. Rather than being created directly, objects are provided by other objects that manage the accumulation register. For example, this object represents the register records within a record set.

AccumulationRegisterRecordKey.<name>. Represents a set of values that unambiguously identify register records. The object is used when you need to reference a certain record. For example, it serves as the value of the CurRow property for a table box displaying a list of register records.

Below you will find examples of how 1C:Enterprise script entities are used to operate information registers (listing 28.9).

Listing 28.9. Sample uses of objects

(1)	// Global context
	// AccumulationRegisters
	
// Example: Recalculate all tottals from the BalanceOfMaterials register.
AccumulationRegisters.BalanceOfMaterials.RecalcTotals();

(2)	// AccumulationRegistersManager object
	// .<accumulation register name>
	// [<accumulation register name >]
	// For Each ... In ... Do ... EndDo;
	
//	Example: Calculate totals from the BalanceOfMaterials for the specified date.
RegisterName = BalanceOfMaterials;
AccumulationRegisters[RegisterName].SetTotalsPeriod(SpecifiedDate);

(3)	// AccumulationRegisterManager.<name> object
	// CreateRecordKey()
	
// Example: Activate the desired row in the accumulation register list.
KeyFieldStructure = New Structure;
KeyFieldStructure.Insert("Recorder", Documents.ReceiptOfGoodsBill.FindByNumber("0000002"));
KeyFieldStructure.Insert("LineNumber", 2);
Items.Materials.CurrentRow = AccumulationRegisters. BalanceOfMaterials.CreateRecordKey(KeyFieldStructure);

(4)	// AccumulationRegisterManager.<name> object
	// CreateRecordSet()
	
// Example: Get register records made by a document.
WantedDocument = Documents.ReceiptOfGoodsOfGoods.FindByNumber(4);
RegisterRecords = AccumulationRegisters. BalanceOfMaterials.CreateRecordSet();
RegisterRecords.Filter.Recorder.Value = WantedDocument;
RegisterRecords.Read();

(5)	// AccumulationRegisterManager.<name> object
	// Select()
	// SelectByRecorder()
	
// Example: Select all of the current month’s records form the BalanceOfMaterials register.
Selection = AccumulationRegisters. BalanceOfMaterials.Select(BegOfMonth(CurrentDate()), EndOfMonth(CurrentDate()));

(6)	// AccumulationRegisterRecordSet.<name> object
	// [<collection element index>]
	// For Each ... In ... Do ... EndDo;
	
// Example: Get register records made by a document.
WantedDocument = Documents.ReceiptOfGoodsOfGoods.FindByNumber(4);
RegisterRecords = AccumulationRegisters. BalanceOfMaterials.CreateRecordSet();
RegisterRecords.Filter.Recorder.Value = WantedDocument;
RegisterRecords.Read();
For Each NextRecord In RegisterRecords Do
	// register records processing algorithm
	...
EndDo;

Sequence of Events when Writing an Accumulation

Register Record Set from a Record Set Form

1C:Enterprise 8. Practical Developer's Guide. Developer's Quick Reference

Fig. 28.20. Sequence of events when writing an accumulation register record set from a record set form

NOTE

Filled events are those executed in the writing transaction.

Accounting Registers

1C:Enterprise Script Entities for Operations on Accounting Registers

The following chart demonstrates interaction between 1C:Enterprise script entities and the accounting registers (fig. 28.21).

1C:Enterprise 8. Practical Developer's Guide. Developer's Quick Reference

Fig. 28.21. 1C:Enterprise script entities for operations on accounting registers

NOTE

Filled boxes indicate data manipulation objects.

LEARN MORE!

For details on major types of 1C:Enterprise script entities, see "1C:Enterprise Script Entities for Operations with Application Data".

AccountingRegisterRecord.<name>. Used to access accounting register records. Rather than being created directly, objects are provided by other objects that manage the accounting register. For example, this object represents the register records within a record set.

AccountingRegisterExtDimensions.<name>. A collection of values of extra dimensions for accounting register records. Values for a specific extra dimension are set or received using the [] operator, as a parameter

that gets the extra dimension type, or using the name of a predefined extra dimension.

AccountingRegisterRecordKey.<name>. A set of values that unambiguously identifies a register record. The object is used when you need to reference a certain record. For example, it serves as the value of the CurRow property for a table box displaying a list of register records.

The properties and methods of interactions between the above objects are generally similar to those of the objects intended to work with accumulation registers (see "1C:Enterprise Script Entities for Operations on Accumulation Registers").

Sequence of Events when Saving an Accounting Register Record Set from a Form

1C:Enterprise 8. Practical Developer's Guide. Developer's Quick Reference

Fig. 28.22. Sequence of events when saving an accounting register record set from a form

NOTE

Filled events are those executed in the writing transaction.

Calculation Registers

1C:Enterprise Script Entities for Operations on Calculation Registers

The following chart demonstrates interaction between 1C:Enterprise script entities and the calculation registers (fig. 28.23).

1C:Enterprise 8. Practical Developer's Guide. Developer's Quick Reference

Fig. 28.23. 1C:Enterprise script entities for operations on calculation registers

NOTE

Filled boxes indicate data manipulation objects.

LEARN MORE!

For details on major types of 1C:Enterprise script entities, see "1C:Enterprise Script Entities for Operations with Application Data".

CalculationRegisterRecord.<name>. Used to access calculation register records. Rather than being created directly, objects are provided by other objects that manage the calculation register. For example, this object represents the register records within a record set.

CalculationRegisterRecordKey.<name>. Represents a set of values that unambiguously identify register records. The object is used when you need to reference a certain record. For example, it serves as the value of the CurRow property for a table box displaying a list of register records. CalculationRegisterRecalcs.<name>. Manages the managers for all the calculation register recalculations.

RecalculationManager.<name>. The recalculation manager is intended to get the recalculation record set.

RecalculationRecordSet.<name>. The recalculation record set.

RecalculationRecord.<name>. Used to access recalculation records.

ActualActionPeriod. An array of values of the type ActualActionPeriodItem.

ActualActionPeriodItem. An actual action period item.

The properties and methods of interactions between the above objects are generally similar to those of the objects intended to work with accumulation registers (see "1C:Enterprise Script Entities for Operations on Accumulation Registers").

Sequence of Events when Saving a Calculation Register Record Set from a Form

1C:Enterprise 8. Practical Developer's Guide. Developer's Quick Reference

Fig. 28.24. Sequence of events when saving a calculation register record set from a form

NOTE

Filled events are those executed in the writing transaction.

Exchange Plans

1C:Enterprise Script Entities for Operations on Exchange Plans

The following chart demonstrates interaction between 1C:Enterprise script entities and the exchange plans (fig. 28.25).

1C:Enterprise 8. Practical Developer's Guide. Developer's Quick Reference

Fig. 28.25. 1C:Enterprise script entities for operations on exchange plans

NOTE

Filled boxes indicate data manipulation objects.

LEARN MORE!

For details on major types of 1C:Enterprise script entities, see "1C:Enterprise Script Entities for Operations with Application Data".

ExchangeMessageWriter. An object used to set up data exchange message writing.

ExchangeMessageReader. An object used to receive data exchange message records. When reading is initiated, it checks whether the message header is valid and rejects invalid messages. When reading is complete, this object changes the value of the ReceivedNo attribute for the corresponding exchange plan node based on received message's number.

The properties and methods of interactions between the above objects are generally similar to those of the objects intended to work with catalogs (see "1C:Enterprise Script Entities for Operations on Catalogs").

Sequence of Events for Writing an Exchange Plan

Node from Node Form (Save and Close)

1C:Enterprise 8. Practical Developer's Guide. Developer's Quick Reference

Fig. 28.26. Sequence of events when writing exchange plan node from a node form

NOTE

Filled events are those executed in the writing transaction.

Leave a Reply

Your email address will not be published.

 

1C:Enterprise Developer's Community