Internet Windows Android

1c 8 create a directory group. Subordinate directories

V. V. Klyuev

http://prof1c.kklab.ru

Subordinate directories

Most likely, you have already repeatedly noticed in usual typical configurations interconnected directories, when when you select an element of the directory (directory1), the value of another directory (directory2) is "filtered" by this value - that is, values ​​that belong only to the current element of the directory1 are selected; for example, it is the Directory "Departments" owned by the Directory "Organizations".

In order to immediately grasp 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 information base and create 2 directories in the configurator.

Reference1 and Reference2. In the reference2 go to the "Owners" tab and select the owner - "Reference1", see as shown in the figure.

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

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

Let's create a form attribute with the "Reference1Link" data type, named "SelectionReference1", and drag this attribute onto the form, set the title "Reference1".


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

8.2, 8.3 Managed forms

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

In the procedure, enter the following text:

& OnClient Procedure SelectionReference1OnChange (Item) List. Selection. Elements. Clear (); // SelectionItem = List. Selection. Elements. Add (Type (" DataCompositionSelectionElement")); SelectionElement. LeftValue = NewDataCompositionField (" Owner "); SelectionElement .ComparisonView = DataComparisonView. Equal; SelectionElement. Usage = True; SelectionElement. RightValue = SelectionDirectory1; SelectionElement .IndexDisplay Mode = BackdropDisplay Mode.

8.2 Common forms


When constructing forms, everything is the same, only the forms must be created as usual, managed forms v normal application does not work.
The difference will be in the selection procedure for the item in the form of a list and in the creation of the props.
To add details to a regular form, click the button

Procedure Reference1OnChange (Item) ThisForm. Selection. Owner. Value = Directory1. Link; This Form. Selection. Owner. Usage = True; This Form. Elements of the Form. Reference List. Customize Selection. Owner. Availability = False; // (?) EndProcedure

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

Video (no sound - everything is clear without sound)

Purpose of directories

The reference book stores a list of possible values ​​of a particular object or attribute. References are used when it is necessary to exclude ambiguous ccod information. For example, so that the buyer, seller, storekeeper and director understand which the product goes speech, everyone should call it the same. And in this case, we need a reference book. Usually in a trading enterprise, it looks like a price list.

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

From the user's point of view, it should be borne in mind that in the Configurator, not the reference itself is created, like a list of values, but a template for the reference, its template is developed. During the configuration process, the structure of the information that will be stored in the reference book is described, the on-screen and, if necessary, print representation of the reference book is developed, and various features of its behavior are set.

Directory details (fields)

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

In addition to the Code and the Name, the 1C: Enterprise system directories can store any additional information about the directory element. To store such information, additional details (fields) can be created in the reference book. Using the mechanism of the directory details, it is easy to organize, for example, an employee card index. For example, the Employees directory will almost certainly have the requisites Position, Salary, Date of Admission, and others. The 1C company anticipated the programmers and introduced two mandatory (predefined) details to all directories: Code and Name. Indeed, almost any real-life object 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 book 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 attribute Position has the data type Positions. In this case, the values ​​of this variable will be selected from the Positions lookup. This is how the simplest connection between directories is realized, when the values ​​of the attributes 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 lower levels of the multilevel reference book. The use of multilevel directories allows you to organize the entry of information into a directory with the required level of detail. Elements and groups of elements in a multilevel directory can be transferred from one group to another.

Subordinate directories

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

Tabular parts

Starting with version 1C 8.0, the platform has implemented the ability to specify one or more tabular sections for a reference book element. It is recommended to use this feature to reflect information associated with a given element, but that does not have its own entity (for which it is recommended to create subordinate directories). For example, for the Employees directory, the tabular sections Education and Family Composition can be created. Work with tabular sections is similar to working with subordinate references, except that tabular sections 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) run on the server side. Additional information see in the section.

1. Reference to the reference book

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

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

2. Creation and recording of a new element of the directory

NewEl = Reference books. Employees . CreateElement ();
NewEl. Name = "Petrov Petr Petrovich";
NewEl. Salary = 25000;
NewEl. Write (); // it is at this moment that a write to the database occurs

3. Creation and recording of a new group of the directory (for a hierarchical directory)

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

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

4. Search for a directory item

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

FoundSotr = RefSotr. FindByCode (123); // search by code
FoundSotr = RefSotr. FindByDescription("Ivanov Ivan Ivanovich"); // by name
FoundSotr = RefSotr. FindByProps("Salary", 5000); // by props

If FoundSotr = Undefined Then
// item not found
EndIf;

5. Deleting a catalog item

SprSotr = Directories. Employees ;

Ref. Delete (); // direct deletion of the current catalog item

Ref. SetBreakRemove(True); // mark for deletion
Ref. SetBreakRemove(Lie); // unmark for deletion

// you can check if the item is marked for deletion
// the Deletion Mark property is of type Boolean (True or False)

Remark = RefSotr. Deletion Mark; // note: this is a property
If Remark = True Then
// the item is marked for deletion
EndIf;

6. Enumeration of the elements of the directory

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

End of Cycle;

7. Parent. Looping through the elements within the group.

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

SprSotr = Directories. Employees ;
GroupWorkers= Demand FindByDescription("Working");
Sample = Demand Select ( GroupWorkers);
While Sampling. Next () = 1 Cycle

Report ("Employee" + Sample. Name);
End of Cycle;

8. Owner. Looping through the elements of the catalog that belong to an element of another catalog.

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

Sample = Directories. Tax incentives... Select (, Employee); // employee here - link to the employee directory element
While Sampling. Next () = 1 Cycle
// actions with the next element
Inform ("benefit" + Sample. Name);
End of Cycle;


9. Transaction

When creating a set of catalog items, to speed up the work, you can enclose the loop in a transaction. In this case, the real creation of all elements will occur only on the command CommitTransaction (). When using transactions, the action will either be completed in its entirety (all elements of the catalog are created), or not performed at all (in case 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 industry. After all, no one wants that when sending money, they are safely debited from your account, but due to some failure they did not reach the addressee.

SprSotr = Directories. Employees ;
StartTransaction();

For Nom = 1 By 100 Cycle
New = Ref. CreateElement ();
New Name = "New" + String (Nom);
New Write ();
End of Cycle;

CommitTransaction();

Nomenclature groups in 1C 8.3 Accounting are very important, because they are later used for. Also, aggregated accounting is kept on them (costs, proceeds). Don't confuse item groups with groups in (folders). These concepts are completely different.

An unlimited number of items can be included in an item group. In them, you combine the nomenclature, which has a certain commonality, while these positions can be in different groups reference book "Nomenclature" (folders). The same item can only belong to one item group. Moreover, it is imperative to keep separate records of produced goods and servants.

In this article, we will consider in detail what nomenclature groups are, how to take them into account correctly and give an example of filling out this reference book.

Suppose that our company produces wooden furniture, plastic products, and we also provide sawing services. We want the program to take into account production costs and revenues separately for each area.

With the correct indication of the nomenclature groups, we will be able to allocate all costs separately for wooden furniture, plastic products and the services of our woodworking workshop. These costs include not only materials, but also wages employees, taxes and other general production and general expenses.

We advise you to thoroughly approach the formation of the list of nomenclature groups. Not worth doing too a large number of, because you yourself can not get confused later, besides, the analytics will not be enlarged enough.

Go to the "References" section and select the "Item groups" item.

In this form of the list, you can create any item groups. For our example, we'll only add three: Wood Products, Plastic Products, and Sawing Services. The "main item group" was already here by default.

Now it remains for us to indicate at the nomenclature items themselves, which groups they will belong to. This can be done by filling in the tabular section in this reference book.

Reflection of costs and benefits by example

We will reflect the cost accounting for the manufacture of finished products "". In this case, item groups will act as sub-accounts of cost accounts.

After we manufacture finished products and sell them, or our sawing services, product groups will also participate in postings as subkonto.

In order to get analytics in the context of item groups, for example, the production of wood products, the corresponding item group must be indicated both when reflecting costs and when reflecting profits. Otherwise, there is no point in keeping records on them, since the data obtained will still be incorrect.

Reflection of production costs

Consider an example of filling out the document "Production report for a shift", which is located in the "Production" section of the 1C: Accounting 3.0 program. As an example, let's reflect the cost of making a carved chair.

Now let's go to the "Materials" tab of this document and click "Fill". The figure below shows that all the components according to the specification of the carved chair were included in the document already with the filled nomenclature group.

After posting this document in the transactions, you can see that the item group "Products from wood" was displayed as a subconto when writing off the costs of materials.

Realization of finished products

Let's create a new one in the "Sales" section. In it, we will indicate that we are selling our newly produced carved chair to the Kopyta LLC organization. When you select an item in the tabular section of the document, the item group "Products from wood" will also be set automatically.

As a result of this document, all of its movements have a subkonto reflecting the same nomenclature group that was in the production report for the shift. It is very important that they match.

In the 1C Accounting 3.0 program, there are many different standard reporting that displays accounting by item groups. For example, the balance sheet of the account, reference-calculations at the cost price at the end of the month, etc.

Now we will analyze one very important issue. 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 mainly for convenience only. Instead of dumping all the elements of the directory into one big heap, they can be sorted, for which there are groups in 1C Enterprise.

However, not all directories allow you to create groups. Below is an example of a reference where grouping cannot be used.


The figure shows that in this reference you can only create the elements rather than a group of elements. A new element is added to the directory by the corresponding button with a green plus ( 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 indicated by folder icons like in Windows Explorer.

site_

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

site_

Honestly, Attempts to expand the tree of groups are surprising, provided that there is nothing there! If groups were not added to the directory, then there will be EMPTY!

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

site_

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

How to use groups when creating catalog items

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

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

Below is an example of creating a fixed asset immediately in the "Administration" group. In this case, the group means a division of the company.

site_

Moving directory 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 a different folder. This method is simple, but ineffective when changing a group for several elements at once.

Second way- select the required element and press the button Move item to another group on the toolbar of the reference book. 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 directory elements, but also to the groups themselves!

Let's sum up

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

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

It should also be noted that in the reference Nomenclature the groups define the accounting accounts, so the entry of the item of this handbook in one of the groups makes sense (and what else). Features of working with a reference book Nomenclature 1C Accounting 8 are considered in

Find a directory item in 1C 8 in three ways:

1) Search by code

If known code element of the directory, and you need to get a link to it, then you can use the method FindByCode (<Код>, <ПоискПоПолномуКоду>, <Родитель>, <Владелец>) code catalog item and as a result you will receive either a link to a catalog item, or an empty link if an item with such a code is not found. It should be noted that if several elements with the specified code are present in the lookup, the one that is found first will be returned.

FoundElement = Directories.Nomenclature.FindByCode ("00000011254");

Description of method parameters FindByCode:

  • <Код>(mandatory)... Type: Number, String. Description: the required code, string or number, depending on the settings of the guide in the configurator.
  • <ПоискПоПолномуКоду>(optional)... Type: Boolean. Description: defines the search mode by the full code, true - the desired code should be specified as a string consisting of a sequence of codes by directory levels, separated by the “/” symbol. The default is False.
  • <Родитель>(optional)
  • <Владелец>(optional)

2) Search by name

If known Name catalog element and you need to get a link to it, then you can use the method FindByDesign (<Наименование>, <ТочноеСоответствие>, <Родитель>, <Владелец>) directory manager. In the simplest case, it is necessary to transfer this method Name catalog element and as a result either a link to a catalog element or an empty link will be obtained if an element with such a name is not found. It should be noted that if the directory contains several elements with the specified name, then the one that is found first will be returned.

FoundElement = Directories.Nomenclature.FindByName ( "Welding machine");

Description of method parameters FindByDescription:

  • <Наименование>(mandatory)... Type: String. Description: a string containing the name you are looking for.
  • ExactMatch> (optional)... Type: Boolean. Description: defines the full match search mode, the search will be successful if the search string: in the case of a parameter value Lie- will correspond to the left side of the name, in the case of a parameter value True- will exactly match the name (except for the "trailing" spaces in the name). The default is False.
  • <Родитель>(optional)... Type: ReferenceLink. Description: the parent within which you want to search, if not specified, then the search will be performed in the entire directory.
  • <Владелец>(optional)... Type: ReferenceLink. Description: the owner within which you want to search, if not specified, then the search will be carried out in the entire directory.

3) Search by arbitrary props

If the value of any props reference book and you need to get a link to it, then you can use the method FindByProps (<ИмяРеквизита>, <ЗначениеРеквизита>, <Родитель>, <Владелец>) directory manager. In the simplest case, you need to pass to this method the name of the attribute, its value, and the result will be either a link to a catalog item, or an empty link, if an element with such a value of the specified attribute is not found. It should be noted that if the lookup contains several elements with the same value of the specified attribute, then the one that is found first will be returned.

FoundElement = Directories.Nomenclature.FindByDescription ("SKU", "A-255");

Description of method parameters FindByProps:

  • <ИмяРеквизита>(mandatory)... Type: String. Description: the name of the attribute, as specified in the configurator, by the value of which the search is performed. Value type: arbitrary, except forValueStore and arbitrary-length strings.
  • <ЗначениеРеквизита>(mandatory)... Type: Free. Description: the value of the variable by which the search should be performed.
  • <Родитель>(optional)... Type: ReferenceLink. Description: the parent within which you want to search, if not specified, then the search will be performed in the entire directory.
  • <Владелец>(optional)... Type: ReferenceLink. Description: the owner within which you want to search, if not specified, then the search will be carried out in the entire directory.