1C:Enterprise script objects used for operations with constants
The following chart shows the interaction between 1C:Enterprise script objects used for operations with constants (fig. 29.1).
Fig. 29.1. 1C:Enterprise script objects used for operations with constants
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.
ConstantsSet is used to perform read and write operations on a set of constants (which can include all available constants). It is also used in constant forms to store, read, and write constants.
ConstantValueManager.<name> is used to access constants. Writing a constant (interactively in a form, or using ConstantsSet, or using ConstantManager.<name>) creates an object of this type and calls the module of that object and its event handlers.
For operations with constants that involve 1C:Enterprise script objects, see listing 29.4.
Listing 29.4. Object usage examples
1. // Global context // Constants // Example: assigning a value to a constant. Constants.Accountant.Set("Patrick Henry Brewster"); 2. // ConstantsManager object // .<constant name> // [<constant name>] // For Each … In … Do … EndDo; // Example: reading a constant value. Result = Constants.NumberingPrefix.Get(); Message("NumberingPrefix constant value = "+ Result + "."); // Example: setting NumberingPrefix constant value to CI. Constants["NumberingPrefix"].Set("CI"); Message("New value = " + Constants["NumberingPrefix"].Get() + "."); // Example: clearing values of all constants. For Each NextConstant In Constants Do NextConstant.Set(Undefined); EndDo; 3. // ConstantsManager object // CreateSet() // Example: assigning new values to several constants. Set = Constants.CreateSet("CEO, Accountant"); Set.CEO = "Thaddeus Addison"; Set.Accountant = "Alexandra Swain"; Set.Write(); 4. // ConstantsManager.<name> object // CreateValueManager() // Example: displaying values of all constants available in the configuration. For Each NextConstant In Constants Do ConstName = NextConstant.CreateValueManager().Metadata().Name; ConstValue = NextConstant.Get(); Message("Constant "+ ConstName + " = " + ConstValue + "."); EndDo;
Event sequence for writing constants from constant forms (save and close)
Fig. 29.2. Event sequence for writing constants from a constant form
Note. Yellow boxes indicate events executed in the writing transaction.
Constant forms are accessed using the ConstantsSet object, which in turn uses the
The internal implementation of the ConstantsSet object defines that when a set of constants is being written the FillCheckProcessing(), BeforeWrite(), and OnWrite() event handlers from the constant value manager module are called for each constant in the set.