Internet Windows Android

Quickly. Subordinate directories

One of the fundamental elements of any 1C configurations are directories. They store information that is used in most other objects of the 1C application. That is why, when developing or upgrading any system on the 1C platform, new directories are first added and filled in. Every 1C developer should know the basic properties, functions and capabilities of these configuration objects.

The structure and functions of directories in 1C 8.3

The main function of directories is to store and provide reference information. Accounting in 1C systems is carried out in the context of directories: Nomenclature, Clients and others.

Developers distinguish a separate type of directories - classifiers. These include information approved, for example, by the state:

  • Units;
  • Currencies;
  • Countries of the world;
  • Professions.

According to their structure, directories in the 1C program are lists of certain data. To get acquainted with the existing directories in the 1C configuration, you need to enter it in the configurator mode. Find the "References" branch in the configurator tree and expand it.

Each of the directories has its own properties set by the developers. Consider the main properties on the example of the reference book "Currencies".

The "Basic" tab contains information about the name of the directory and its description. The next section "Subsystems" is responsible for including the directory in a specific subsystem.


The "Functional options" tab defines the functionality using the lookup. The "Hierarchy" tab allows you to create nested directory elements. Hierarchical types of directories can be extremely useful.


On the "Owners" tab, the subordination mechanism is configured. If the directory is subordinate to another, then filling in the props "Owner" is mandatory.

On the "Data" tab, it is determined what information you can add to the 1C directory. At the top, the code and name are configured - one of the standard details, in the center - a list of added details. At the bottom you see tabular parts of the directory.


The numbering settings of the configuration object in 1C allow you to create a unique numbering for the elements of the directory.


On the Forms tab, developers create interfaces that will be visible to users. The most common forms are Element and List: this is how users see a list of directory data and its elements in the 1C program.


Proper setting of parameters on the "Input field" tab will create the most convenient working conditions for users. The Quick Select/Enter by String/Full Text Search options will help you find the item you're looking for. "History selection as you type" will save previously used positions.


The "Commands" section shows a list of existing buttons that call this directory. In "Layouts" you can find all the printables of a particular configuration object. “Input based on” will be affected by the developer in cases where other configuration objects are planned to be created based on the directory element.


The "Permissions" subsection reflects information about which roles include access to the directory, including filling out directories, editing and reading. "Data Exchange" will tell you which exchange plans the directory participates in. The last tab includes the ability to go to modules to write procedures and functions. There is also a list of predefined dictionary values ​​that can be accessed directly in the code.


Not all properties are required. Some tabs remain untouched throughout the life of the software on the 1C platform.

To make creating directories in 1C easy, let's create a new configuration object of this type.

Creating and transferring a directory to 1C 8.3

Using an example of a non-standard configuration, we will create and start using the "Subdivisions" directory, which will store data on the structure of the enterprise. In the configurator, in the configuration tree, find "References" and click the "Add" button. Fill in the fields:

  • Name/Synonym. The first attribute is responsible for the name of the object in the configuration, the second - for the name in the enterprise mode;
  • The object representation is used when opening one element of the directory;
  • The list view is used when viewing a list of reference data;
  • Explanation - help for users.


Next, we need to add a new directory to one of the subsystems if we want users to be able to see it in the interface. Open the "Subsystems" tab and check the box next to the already existing "General" subsystem.


Our new directory will be hierarchical, as divisions can be included in one another. Groups of departments are not planned at our enterprise, so the type "Hierarchy of elements" is selected. At the same time, we will not limit the nesting of subdivisions.


In addition to the standard set, we need a few more details and a tabular part for the list of employees. To do this, you need to add them on the "Data" tab in the relevant sections.


For convenience, you need to add our details to the list form. To do this, on the "Forms" tab, create a new list form and set it as the main one. In the dialog box, check the boxes for all the details that we need. We will also set the form of the element in order to arrange the details in the order that suits our users.


This completes the creation of the demonstration directory "Subdivisions". We update the configuration and start the system again in enterprise mode. In the "General" subsystem, the "List of departments" function key appeared. Clicking on it opens the directory list form we specified with the ability to add elements to it.


Many companies work with several 1C databases, so the developer may be faced with transferring the created directory to another database. To do this, along with most configurations, an external processing is supplied - "Uploading and loading XML data". But before transferring directories 1C 8.3, it is necessary to prepare the receiver configuration. A similar configuration object with identical fields and tabular parts should be created in it.

When opening this processing, we need to specify which objects we want to transfer and select a file. Then the directory unloading launched creates an XML file where it writes all the data.


To upload directories to another infobase, you need to go into it and open the same external processing. On the second tab, start the download. This is a manual mechanism, so if you plan to regularly enter new elements of the directory in one database, then it is better to organize an exchange between databases.

In conclusion, I would like to recall that creating directories in 1C 8.3 after the system is put into operation will cause problems due to the need for exclusive access to the database. It is safest to update the configuration on the server.

1C directories is a specialized object of the metadata tree, which is used to store static information of a reference nature. For example, in typical configurations, you can see the following views: , Nomenclature, Employees, Fixed assets, etc. Information in directories, as a rule, often does not change. Reference books are further used in almost all accounting objects as an accounting section or reference information.

Below we will consider setting up and designing a reference book from the configurator using the “Nomenclature” reference book as an example.

General tab

The "Basic" tab indicates the name, synonym, representation of objects, description of the purpose.

Directory Hierarchy tab

Here the directory hierarchy is set.

Hierarchy in 1C 8.3 is of two types - " groups and elements" and " elements". It differs in that in the first case, only a folder (group) can be a parent (folder), and in the second case, an element can also be a parent.

"Place groups on top" - the flag is responsible for displaying groups in the form of a list.

Also in the settings, you can limit the number of groups in the directory hierarchy by the corresponding setting.

Owners Tab

A directory can be subordinate to another directory. From the point of view of configuring 1C 8.3, this means that the attribute "Owner" becomes mandatory for the subordinate element. An example of such a connection of directories in the typical configurations "Nomenclature - Units of Measurement", "Contractors-Counterparties Agreements".

The directory owner can also be the following metadata objects: , .

Data Tab

Get 267 1C video lessons for free:

The most important tab from a programmer's point of view. It contains the details of the directory.

The directory has a set of standard details that are not edited by the 1C 8.2 programmer, a list of them can be seen by clicking the "Standard details" button:

I will dwell on each in more detail:

  • This group— attribute with boolean type, indicating whether it is a group or an element. Available only in the hierarchical directory. Note, the value of this attribute cannot be changed in 1C: Enterprise mode.
  • The code- attribute, type number or string (usually string). A number assigned automatically by the system. Typically calculated as (previous code + 1). I recommend using the string type, because the sorting of numeric values ​​does not work as it should. Can be used as a lookup view in the list and in input fields. Typically used to search for an element when typing in a string. If you need to remove the Code field, specify zero in the string length.
  • Name— attribute required to be filled in, string type. The maximum line length is 150 characters. Can be used as a lookup view in the list and in input fields. Typically used to search for an element when typing in a string. If you need to remove the Name field, specify zero in the string length.
  • Parent— an attribute of the ReferenceReference type.<ИмяТекущегоСправочника>. Available only in the hierarchical directory. Points to the highest parent in the hierarchy. If the Element or Group is in the directory root, the Directory value is specified.<ИмяТекущегоСправочника>.EmptyReference.
  • Owner— link to the element-owner of the current element (group) of the directory. Available only in the subordinate directory 1C.
  • FlagRemoval— props with boolean type. Responsible for displaying "deletion mark" in the system. An element marked for deletion is considered unusable, but old movements in documents may remain on it.
  • Link— field of string type. This attribute stores a unique object identifier - GUID. What we see in the system in a visual display called "link" is just a representation of the object. Can't be changed.
  • Predefined- boolean type, displays whether the element is predefined, more on that later. Can't be changed.

The "Data" tab also indicates the representation of the directory in the system; before version 8.2.16, the representation could only be a Code or Name. In recent versions of the platform (starting from 8.3), the view can be described independently in the manager module using the "ProcessingViewReceivingProcessing" handler.

Numbering tab

Here you can specify the settings for the reference in terms of numbering. It is recommended to use autonumbering. Uniqueness control is a flag that helps, if necessary, to make the code unique. If, with the flag set, you try to write a directory element with a non-unique code, you will receive a message in 1C "The directory code has become non-unique."

A series of codes - determines how to number the directory, you can enter the numbering of the directory in the context of the owner. For example, the counterparty "Horns and Hooves" will have its own contract numbering - "1, 2, 3", etc.

Forms tab

Here are the forms for the reference book. If the configuration is launched in both normal and managed modes, then there will be two tabs with forms by default: “main” and “additional” — different for a normal and managed application.

This page has an important reference property - "". This is a very convenient 1C 8 function that allows you, when filling in the data in the input field, not to enter the directory, but to type its name, code, or the like. and select the desired element from the drop-down list. It looks like this:

Other Tab

On the tab, you can get quick access to the main modules of the directory - the object module and the manager module.

You can also define a list of predefined lookup elements on the page. These are items that cannot be deleted in Enterprise Mode. Predefined elements can be accessed directly in the configurator, by name, for example: Catalogs.Nomenclature.Service.

This tab also defines the blocking mode - automatic or managed. Using full-text search, as well as reference information about the directory, available in 1C: Enterprise mode.

Klyuev V.V.

http://prof1c.kklab.ru

Subordinate directories

Most likely, you have already repeatedly noticed in the usual typical configurations interconnected directories, when when selecting an element of the directory (reference1), the value of another directory (reference2) is “filtered” by this value - that is, the values ​​belonging only to the current element of the directory1 are selected; for example, this is the “Subdivisions” Directory owned by the “Organizations” Directory.

In order to immediately understand the essence of what is happening, let's see what happens in practice. To do this, you can create an empty configuration from scratch, or go to any existing copy of the infobase and create 2 directories in the configurator.

Handbook1 and Handbook2. In directory2, go to the "Owners" tab and select the owner - "Catalog1", see as shown in the figure.

Now, when creating items in "Directory2", the system will ask you to enter the owner of the catalog1. There is an option - Use subordination - when subordination is given to Elements, groups, or groups and elements.

It would seem that everything is simple, but users have problems. When opening the “Directory2”, the user sees all the elements in a completely incomprehensible order, and besides, if you worked with typical configurations, you might notice that you do not set the owner anywhere directly in the “Divisions” directory, and when opening the directory you can choose organization and, depending on this, receive elements subordinate to one organization or another; at the same time, when creating an element of the "Subdivisions" directory, by default you will receive the owner who was selected in the form of a list of subdivisions.
So let's get started and create a "List Form" for our "Directory2", while providing it to 1C without making any changes, later we will correct the form created by the designer.
In Directory2, go to the Forms tab and add (+) a new Directory List Form and click Finish.

Let's create a form attribute with the data type "Directory1.Link", with the name "SelectionDirectory1", and drag this attribute onto the form, set the title "Directory1".


Now, in order for "this miracle" to work, you need to write a code that will perform a selection when selecting the Directory Element1.

8.2, 8.3 Managed Forms

In order to display in the form of a directory list only the elements we need for the selected element of the Directory1, it is necessary to programmatically make a selection - for the selected element, for this we will use the predefined procedure of the SelectionCatalog1 control element, and write the code that performs the specified task.
In the upper part, select "SelectionDirectory1", right-click and select "Properties", in the window that appears, find the "OnChange" property and click the magnifying glass, thereby going to the form module; the procedure "SelectionDirectory1OnChange(Element)" is automatically created

In the procedure, enter the following text:

& On the Client Procedure SelectionCatalog1OnChange(Element) List. Selection. Elements. Clear() ; // SelectionElement = List. Selection. Elements. Add(Type(" Data Layout Selection Element" ) ) ; FilterElement.LeftValue = New DataCompositionField("Owner" ) ; FilterElement.ComparisonType = DataCompositionComparisonType. Equal to; FilterElement. Usage = True ; FilterElement.RightValue = SelectionCatalog1; FilterElement.DisplayMode = DisplayModeElementDataCompositionSettings. Inaccessible; EndProcedure

8.2 Common forms


When building forms, everything is the same, only forms need to be created ordinary, managed forms do not work in a normal application.
The difference will be in the selection procedure for the element in the list form and the creation of the attribute.
To add props to a regular form, click the button

Procedure Reference1OnChange(Element) ThisForm. Selection. Owner. Value = Directory1. Link; ThisForm. Selection. Owner. Usage = true ; ThisForm. ElementsForm. DirectoryList. Selection setting. Owner. Availability = False ; //(?) EndProcedure

The penultimate line (?) - we prohibit changing the selection when opening the selection parameters by the user - only through the control!

Video (no sound - everything is clear without sound)

Now we will analyze one very important question. THIS is a rake that almost every first user of 1C Accounting 8 steps on! Yes, yes, now we will talk about groups.

General information about groups in 1C Accounting 8

Groups are found in directories and are mostly for convenience only. Instead of dumping all the elements of the directory into one big pile, they can be sorted, for which there are groups in 1C Enterprise.

However, not all directories allow you to create groups. The following is an example of a lookup that cannot use grouping.


The figure shows that in this directory you can only create elements, not element groups. A new element is added to the directory by the corresponding button with a green plus sign ( Add in version 8.2 or Create in 8.3). Elements of directories in the list are indicated by a picture in the form of a stick (on the left of the line).

And here is an example of a directory in which, in addition to elements, you can also create groups. Groups are also often called folders, as they are represented by folder icons, as in Windows Explorer.

site_

As you can see from the figure above, directories that have , consist of two parts. In addition to the usual list of elements , there is also a field on the left that displays only groups. By the way, many users are confused by the fact that these same groups are not visible in the left field ( of course, provided that they were added at all). To expand the group tree on the left, you need to click on a very small plus sign, which is double underlined in the picture. And then it will turn out like this.

site_

Honestly, surprising attempts to expand the tree of groups, provided that there is nothing there! If groups were not added to the directory, then it will be empty!

If a lot of data (elements) has accumulated in the directory, then they can be sorted using groups. How many groups to create, how to call them - only you decide.
A new group (folder) is created by pressing Ctrl + F9 or by clicking on the folder button with a plus on the directory toolbar.

site_

Then another typical question arises - what to choose in the field Group with a new group? The fact is that groups, like folders in Windows, can be nested. Therefore, if you want to create a group within a group (a folder within a folder), then in the field Group parent group should be selected, i.e. the one in which the newly created folder will be located. If the new group should be located in the directory root, then this field should be left empty.

How to use groups when creating directory elements

If it is possible to create groups in the directory, then when creating a new element of such a directory, the form will necessarily contain a field Group! What does this mean in practice? Everything is extremely simple - if you want the new directory element to immediately fall into a certain group, then select it in the field Group; if not, the field can be left blank.

There was an important part of the article, but without JavaScript it is not visible!

Below is an example with the creation of a fixed asset immediately in the "Administration" group. In this case, the group has the meaning of a division of the company.

site_

Moving reference items from one group to another

The easiest way to move an element of the 1C Accounting 8 directory to another group is to open this element (F2 key) and in the field Group choose another folder. This method is simple, but inefficient when changing the group of several elements at once.

Second way- select the desired element and click the button Move element to another group on the guide toolbar. The group must already exist! An example is shown in the figure below.

site_

In the window that opens, select the desired group by double clicking (or single, and then the button Select).

Third way the fastest. Items can be dragged with the mouse from one group to another, just like folders and files in Windows.

All of the above can be applied not only to the elements of directories, but also to the groups themselves too!

Summing up

Thus, groups (folders) in directories 1C Accounting 8 are designed to sort the elements of the directory in accordance with the logic of the user of the program. Dividing into groups allows you to quickly find what you need. It does not make any sense (except in some cases), i.e. you can create any number of groups and subgroups, as well as give them any names.

If, when creating a directory element, you need to immediately "put" it into the desired group (folder), then in the field Group form of a new element, select the group you need. If the directory element will lie in its root, then the field Group should be left blank.

It should also be noted that the guide Nomenclature groups define accounting accounts, therefore, entering an element of this directory into one of the groups makes sense (and what else). Features of working with the directory Nomenclature 1C Accounting 8 are reviewed in

Purpose of directories

The directory stores a list of possible values ​​of a particular object or attribute. Directories are used in cases where it is necessary to exclude ambiguousod information. For example, in order for the buyer, seller, storekeeper and director to understand what kind of product they are talking about, everyone must call it the same name. And in this case, we need a guide. Usually at a trading enterprise it has the form of a price list.

The 1C:Enterprise 8 system allows you to maintain an almost unlimited number of necessary directories. Each directory is a list of homogeneous objects: positions, employees, customers, goods, etc. Each such object is called an element of the directory.

From the user's point of view, it should be borne in mind that the Configurator does not create the dictionary itself, as a list of values, but develops a reference template, its template. During the configuration process, the structure of the information that will be stored in the directory is described, a screen and, if necessary, printed representation of the directory is developed, and various features of its behavior are specified.

Directory details (fields)

As mandatory details, each directory has The code and Name. The directory element code can be either numeric or text. The 1C:Enterprise 8 system provides ample opportunities for working with the codes of directory elements: automatic assignment of codes, automatic control of the uniqueness of the code, and others.

In addition to the Code and Name, directories of the 1C:Enterprise system can store any additional information about the element of the directory. To store such information in the reference book, additional details (fields) can be created. Using the directory details mechanism, it is easy to organize, for example, a file of employees. For example, the Employees directory will almost certainly have the details of Position, Salary, Date of Admission and others. Firm 1C anticipated programmers and introduced two obligatory (predefined) details into all reference books: Code and Name. Indeed, almost any object from real life contains these attributes. For example, for employees, the code is the personnel number, and the name is the Last Name, First Name and Patronymic (full name). In addition, the use of codes (when using automatic numbering) makes it easy to understand which element was entered earlier and which later in the database.

Data types

For each reference attribute, you must specify the data type, for example, "number", "string", "date", boolean (True or False). These are basic types, but complex data types can also be specified. For example, the Position attribute has the Position data type. In this case, the values ​​of this attribute will be selected from the Jobs directory. This is how the simplest connection between directories is implemented, when the values ​​of the details of one directory are selected from the elements of another directory.

Hierarchical directories

The list of directory elements in the 1C: Enterprise 8 system can be multi-level. In this case, all lines of the directory will be divided into 2 types: "simple" elements of the directory and groups of the directory. Groups allow you to go to the underlying levels of a multi-level directory. The use of multi-level directories allows you to organize the entry of information into the directory with the desired level of detail. Elements and groups of elements in a multilevel dictionary can be transferred from one group to another.

Subordinate directories

A relationship of subordination can be established between directories. In relational database terms, a one-to-many relationship is established between tables. In this case, each element of the subordinate directory will be associated with one of the elements of the owner directory. Sometimes you can say that the elements of one directory belong to the elements of another. For example, the system may have a directory of the Agreement. Then it can be made subordinate to the Clients directory. This means that the customer owns the contracts and one customer can have multiple contracts.

Tabular parts

Starting with version 1C 8.0, the platform implements the ability to set one or more tabular parts for a directory element. This feature is recommended to be used to reflect information related to this element, but not having its own object entity (for which it is recommended to create subordinate directories). For example, for the reference book Employees, tabular sections Education and Family Composition can be created. Working with tabular parts is similar to working with subordinate directories, except that tabular parts cannot be used as attribute values ​​of other objects.

Where is the program code used to work with directories?

Since we need to access the database to execute the program code, these pieces of program code must be placed in procedures and functions (or modules) performed on the server side. See the section for more information.

1. Link to the guide

To work with a directory from any module, you must first create a link to this directory.

SprEmployees = Directories. Employees ; // or option 2
SprPositions = Directories ["Positions"];

2. Creating and writing a new directory element

NovEl = References . Employees . createItem();
NovEl. Name = "Petrov Petr Petrovich";
NovEl. Salary = 25000;
NovEl. Write(); // this is the moment the database is written to

3. Creating and recording a new directory group (for a hierarchical directory)

new = Directories.Employees. To create a group ();

New . Write();
// or option 2
New = References["Employees"]. To create a group ();
New . Name = "Working";
New . Write();

4. Search for a directory element

// if the element is found, then it is returned, otherwise the value is Undefined

FoundComp = RefComp . FindByCode (123); //search by code
FoundComp = RefComp . FindByName("Ivanov Ivan Ivanovich"); //by name
FoundComp = RefComp . FindBy Props("Salary", 5000); //by attribute

If FoundComp = Undefined Then
//element not found
EndIf;

5. Deleting a directory element

Spectr = Directories . Employees ;

RefStr. Delete (); //immediate deletion of the current directory element

RefStr. SetRemoval Flag(True); // mark for deletion
RefStr. SetRemoval Flag(Lie); //unmark for deletion

//can check if the element is marked for deletion
// property Delete Mark is of type Boolean (True or False)

Flag = RefStr . FlagRemoval; //note: this is a property
If Flag = True Then
//element marked for deletion
EndIf;

6. Iterating over the elements of the directory

Selection = Directories . Employees.Select();
// start iterating over the elements of the dictionary in a loop
//actions with the next element...

EndCycle;

7. Parent. Iterate over elements within a group.

A group in terms of 1C is a "parent".

Spectr = Directories . Employees ;
GroupWorking= RefStr . FindByName("Working");
Sample = SprStr. Select ( GroupWorking);
While the selection. Next() = 1 Loop

Report ("Employee" + Sample . Name);
EndCycle;

8. Owner. Iterating over the elements of a dictionary that belong to an element of another dictionary.

One directory is subordinate to another directory, for example, the Tax Benefits directory is subordinate to the Employees directory.

Selection = Directories . Tax Benefits. Select (, Employee ); //here employee - a link to the employee directory element
While the selection. Next() = 1 Loop
//actions with the next element
Report ("benefit" + Sample . Name);
EndCycle;


9. Transaction

When creating many reference items, to speed up work, you can enclose the loop in a transaction. In this case, the real creation of all elements will occur only by the command FixTransaction(). When using transactions, the action will either be performed entirely (all elements of the directory are created), or not performed at all (in the event of any failure, not a single new element will be created, everything will remain the same as before the transaction was started). Transactions are widely used in the banking sector. After all, no one wants that when sending money, they are safely debited from your account, but due to some kind of failure they did not reach the addressee.

Spectr = Directories . Employees ;
StartTransaction();

For Nom = 1 to 100 Cycle
New = RefStr . createItem();
New . Name = "New" + String(Nom);
New . Write();
EndCycle;

CommitTransaction();