Good day.

Today we’ll talk about the innovation in platform 8.3 regarding predefined elements.

Introduction

Let me remind you that earlier in practice, very often I wanted to look at a directory element to find out its predefined name. For example, you created two predefined counterparties and named them IPSidorov and OOOMeteor. And they sewed some logic onto them.

When everything was debugged and worked out, it turned out that the task was posed in reverse and the logic for the individual entrepreneur was needed for the LLC, and the logic of the LLC was needed for the individual entrepreneur. “No problem,” we say, and in enterprise mode we rename the elements. After all, getting into the code is much more difficult. A year passes and you are given a new task: to set up some more logic for IP Sidorov. You go into the configurator, write logic, start checking and nothing works, because... in the IPSidorov configurator, and in the enterprise - OOOMeteor. The brain is broken and I want to destroy this rake. The simplest and most obvious thing is to display the name of a predefined element in the form of a list. Here’s the catch: you can only get the name of a predefined one in 8.2 using the method. But the method has its own inconveniences; it cannot be obtained in a request. Those. The first inconvenience is to get the name of the predefined one from a reference to the directory.

The second inconvenience is when we already have a directory element and we need to make it predefined. We create a predefined element and get two elements in the directory. One is predefined, the other is operational, which is referenced in all our documents. Replacing links certainly helps, but if the database is large, then it is difficult.

Now to the point

The first is that the directory now has the "Update predefined data" property.

What does this field give us? If it is set to "Do not update automatically", then by adding a predefined element, we will not see it in the directory right away. Those. metadata has nothing to do with the data. And if you do not create it in the directory, then accessing it by its name through the directory manager will cause a syntax error.

Very interesting, but why? How can we create an element in the directory? You can create it however you want, or you can link it to an existing one. Now the directory has the attribute "Name of Predefined Data". We create a directory element programmatically as usual through “Directories.Accounts.CreateElement()” and fill its attribute “PredefinedDataName” equal to the name of the predefined element. Or if the element already exists, we get its object and again fill in the “Name of Predefined Data”. All.

And finally a little syrup

This new attribute is not only available for reading and writing, but it is also available in requests. This way you can impose conditions on it in queries, determine whether it is predefined or not.

Thank you for your attention.

The very idea of ​​programmatic work with predefined elements, in my opinion, is very correct. There are simply nuances that need to be taken into account when working.

First, you need to clearly understand for yourself that there are predefined elements in the configuration and there are predefined elements in the information base (IS). Technically, predefined information security elements are the most common elements of directories, in which the “Name of Predefined Data” attribute indicates which predefined configuration element they correspond to. They are no different from ordinary elements. Accordingly, any ordinary information security element can be made predefined, any predefined element can be made ordinary. To do this, just enter the desired value in the attribute "PredefinedDataName".

From time to time, this property contains a value that is not the one the developer intended. As a result, errors occur in the operation of 1C. From critical, in which work is basically impossible, to non-critical, in which the logic of the algorithms is disrupted.

Conditionally we can distinguish three types of errors:
1. "The predefined element is not in the data";

3. Incorrect specification of a predefined element;

1. "The predefined element is not in the data" - o absence of a predefined element described in the configuration in the information security data.

This is the easiest type of error to debug and correct. Its simplicity is that the platform quite correctly reports this situation “The predefined element is missing in the data” and it is quite clear how to fix it.

When accessing a missing element in the code "Directories.Types of Contact Information.Email of the Contact Person" a message is displayed

When accessing an element in the request "VALUE(Directory.Types of Contact Information.Email of the Contact Person)" the following message is displayed:

This error occurs if an element is described in the configuration, but the element is not associated with it in the database.

To begin with, let us clarify that this situation is not always wrong. It is quite possible to use predefined data in some kind of program logic, which for most users may not be used. In this case, in order not to clutter up the directory for all users of the configuration, it is logical to define predefined elements in the configuration, but not to create them in all information security systems, but only for those information security systems in which the required configuration logic is used. In this case, the programmer can specify the “Do not update predefined data” property for the directory and create elements programmatically when accessing the module functionality. Or allow the user to independently bind predefined module elements to existing regular elements.

Also, automatic creation of predefined elements is not used when working in RIB mode. Since new elements must be transferred from the central database, and not created in nodes with different UIDs.

Those. Sometimes the error is the reference to an unmatched element, not the presence of such an element itself.

It is necessary to analyze why the element was not created. Perhaps it should be created when some program mode is executed. For example, after completing an exchange in RIB. Or perhaps it was just accidentally deleted.

If the logic provides for filling predefined elements not automatically, but in a separate mode, then before using access by name " Directories.Types of Contact Information.Email of the Contact Person"To prevent an exceptional situation, it is advisable to check that the element is already in the database. If the element is missing, then inform the user about this and explain what mode he needs to perform to fill the element. For such a check, you can run a data query.

Request = New Request; Request.Text = "SELECT | Types of Contact Information. Link | FROM | Directory. Types of Contact Information HOW Types of Contact Information | WHERE | Types of Contact Information. Name of Predefined Data = "" EmailContactPerson"""; Item Is MissingInData = Query.Execute().Empty();

If this is still an error in the database data, then it is necessary to bind to a predefined element of the information security element. Those. it is necessary to explain to the system which element the information security should address program code by this name. Technically, a binding is simply specifying the name of a predefined element in the " propertyPredefinedDataName" of the IS element. To install it, just run the code:

2. "The predefined element is not unique" - h double predefined elements:

This situation is that several information security elements are attached to one predefined element. In this case, when accessing a predefined name, the element will be selected randomly. This situation is always wrong. Its difficulty is that the platform does not report it in any way. The algorithms just start working incorrectly.

The platform will report the error "The predefined element is not unique" only when you try to edit a duplicate element.

As long as no one needs to edit the element, no one will know about the error.

Such duplicates can be created, for example, if RIB is used for the directory and the “Update automatically” mode is specified in the properties for predefined data. In this case, when performing an exchange, one instance of the predefined data will be created when the configuration is updated. A second instance of predefined elements with the same name will be transferred from the central database during the exchange.

Also, these duplicates will arise when using exchange processing between configurations if different information security elements correspond to predefined elements in different databases. In this case, one copy of the predefined data already exists in the database, the second will come when loading data with a different UID. If you are performing data transfers, you need to decide which database elements are considered primary and use them in the subordinate database. In the subordinate database, it is necessary to replace the use of old elements with elements of the main database.

Such errors in the database can be identified with a query like:

SELECT Types of Contact Information.Name of Predefined Data, QUANTITY(DIFFERENT Types of Contact Information.Link) AS Number of Predefined FROM Directory.Types of Contact Information AS Types of Contact Information GROUP BY Types of Contact Information.Name of Predefined Data HAVING QUANTITY(DIFFERENT Types of tactInformation.Link) > 1

This query will return a list of predefined elements with which more than one information security element is associated.

If such elements are present, it is necessary to remove the connection with the predefined one for one of them. Those. It is necessary to unambiguously determine for the system which information security element the program code should refer to when using this name. To do this, just run the code.

3. Incorrect specification of a predefined element.

The error is that the predefined element corresponds to an element that is not provided by the program logic. Such errors are the most difficult to diagnose. Unlike the first two types, the configuration cannot be automatically checked for these errors. They can only be identified by analyzing the logic of work. If in doubt, you can check whether the correct element is being used.

To do this, just run one of the commands.

//Defining an information security element that is linked to the desired predefined Notify (Directories.Types of Contact Information.Email of the Contact Person) //Defining a predefined element to which the selected Notify is attached (Link To Element.Name of Predefined Data)

If such errors are identified, it is necessary to remove the incorrect connection with the old element and add a connection with the new element. The operation code is similar to the code for correcting the first two types of errors.

Well, briefly about errors when program work or in configurator mode:

"The predefined element does not belong to<Имя справочника>" - an error occurs when trying to write a predefined element with a name that does not match the name in the configurator.

"Non-predefined objects cannot have predefined subconto view records" - an error occurs when trying to make an element of a predefined chart of accounts unpredefined. To eliminate errors, it is necessary to remove the “Predefined” flag from each element subcontact line.

"Non-predefined objects cannot have predefined records of leading calculation types"- an error occurs when you try to make a predefined element of the plan of calculation types unpredefined. To eliminate errors, it is necessary to remove the “Predefined” checkbox for each line of the element’s leading calculation type.

"Predefined elements not unique"- an error is generated in the configurator when updating the information base for a configuration release without compatibility mode with 8.3.4. It is necessary to check for duplicates and eliminate them before updating.

"The name of the predefined element is not unique" - an error occurs when there are several predefined elements of the same name in the configuration when updating to the platform8.3.6.2332 and higher. It is necessary to eliminate duplicates in the configuration.

To work with predefined data, I recommend processing. It can perform any actions with predefined data, and can also check the configuration as a whole for the presence of errors of the first two types (duplicated and missing elements) in all information security objects (directories, charts of accounts, PVC, PVR).

Simple processing for working with predefined values.

Allows you to compare information security elements with elements predefined in the configuration.

Allows you to check the entire configuration for the presence of duplicated (several information security elements associated with one predefined element - error) and missing elements (predefined elements that are not associated with information security elements - error). Such elements could arise during exchanges or failures and lead to errors in the configuration.

You can simply view the current values ​​and make any necessary changes.

Operating procedure:

1. We start processing.

2. Select the type (directory, chart of accounts, PVC, PVR).

3. We select the directory of the selected type.

4. All predefined elements available in the information security and described in the configuration appear in the tabular part of the processing.

If there are several elements in the database that are tied to one predefined property, or some of the elements described in the configuration are not assigned information security elements, the system will report this when selecting a directory. Duplicate and missing items will appear at the top of the list and will be highlighted in orange.

5. We set new values ​​for the required predefined elements.

In this case, lines for which a predefined element disappears from the configuration are marked in red. The blue ones are the lines for which the predefined element changes, the green ones are the lines for which the predefined element appears.
If there are a large number of duplicates, it is convenient to select all the extra lines with the mouse and indicate for all selected ones the cancellation of the connection with the “Cancel correspondence” button (from version 1.3.1)

6. We perform reassignment by clicking the “Reassign elements” button.

Checking duplicates(error "The predefined element is not unique"):

When you click the "Check duplicates" button, the processing will check all directories, charts of accounts, PVC and PVR and display a list of tables with duplicated elements indicating the number of duplicated elements.

After this, you need to check separately the objects for which errors were found.

Checking missed entries(error "The predefined element is not in the data"):

When you click the "Check Missed" button, processing will check all reference books, charts of accounts, PVC and PVR and display a list of predefined elements that are not associated with information security data.

Requires platform 8.3.3 or higher to use.

Universal, can be used with any configuration.

Detect language Afrikaans Albanian Arabic Armenian Azerbaijani Basque Bengali Belarusian Bulgarian Catalan Chinese (Simp) Chinese (Trad) Croatian Czech Danish Dutch English Esperanto Estonian Filipino Finnish French Galician Georgian German Greek Gujarati Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Kannada Korean Lao Latin Latvian Lithuanian Macedonian Malay Maltese Norwegian Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Tamil Telugu Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Afrikaans Albanian Arabic Armenian Azerbaijani Basque Bengali Belarusian Bulgarian Catalan Chinese (Simp) Chinese (Trad) Croatian Czech Danish Dutch English Esperanto Estonian Filipino Finnish French Galician Georgian German Greek Gujarati Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Kannada Korean Lao Latin Latvian Lithuanian Macedonian Malay Maltese Norwegian Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Tamil Telugu Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish

Close