1C processing for automatic creation of directories. Accounting info

Download universal object processing 1C 8.3.

In a regular application version of the 1C platform 8.2 and 8.1 (on regular forms) there was such a wonderful processing as “Universal selection and processing of objects”. It greatly simplified life for programmers and program administrators.

The same 1C processing has appeared for a managed application (8.3 and 8.2). Before this, in 1C 8.3, it was necessary to make do with standard processing of group changes to details, but it does not solve all the tasks that are required in the daily work of a 1C user or programmer.

Search and selection of objects

After downloading the processing, we can run it as an external one. For those who don’t know, this is done through the “File” – “Open” menu. The processing window will appear:

On the first tab we must select the object we are going to work with. And so, in the “Search object” field the document “Sales (acts, invoices)” is already selected. This is because this object has already been selected before. Processing can remember.

By clicking the “Setting up selection” button, we can set selection for almost any field of the object:

If the selection data is not enough, you can select the necessary objects using a custom query. To do this, move the “Selection mode” switch to the appropriate position.

After all the settings, objects need to be selected. Click on the “Find objects” button and look at the selection result:

Processing elements

Let's go to the "Processing" tab:

Perhaps only the first three treatments are worthy of a separate brief review. The work of the rest is clear by name and they do not require settings.

Arbitrary algorithm

The “Custom Algorithm” processing allows you to write a program of actions on objects in the internal 1C language. Processing requires programming skills and its description is worthy of a separate article. With its help you can do practical actions on objects:

Setting up details

The “Setting details” processing allows you to change the details of selected documents or directories, as well as information registers. Quite useful, and sometimes simply necessary processing. For example, let’s replace the document currency in the selected documents:

It should be immediately noted that processing can be performed immediately, or you can save the setting. This setting will be displayed in the processing tree.

Renumbering objects

The “Renumbering of Objects” processing accordingly allows you to renumber documents or change directory codes. Processing provides a rich set of actions. For example, you decided to change the prefix of the documents that you selected:

Now let's see what we can do with the saved settings. It turns out that we can execute in one batch, transferring it to the “Selected Processings” window:

Now we can sequentially carry out the selected settings by clicking the “Run” button.

Based on materials from: programmist1s.ru

Attention! This is an introductory version of the lesson, the materials of which may be incomplete.

Login to the site as a student

Login as a student to access school materials

Creating 1C configurations: adding processing

We continue to study the basics of creating configurations on 1C.

In this lesson, we will create a new processing together, and then write commands for it that demonstrate how to work with the “Employees” directory.

We return to the configurator and open the configuration tree.

Adding a new processing

Right-click on the “Processing” section and select “Add”:

The window for creating a new processing opens. Let's go to the "Basic" tab and specify "Directory Processing" as the processing name:

Creating a form for processing

Let's go to the "Forms" tab, click on the green plus sign to add a new form (visual representation of our processing):

A form creation constructor has appeared. Let's leave everything as default and click "Finish":

A new form has opened:

Create a new command for the form

Let's go to the "Commands" -> "Form Commands" tab:

Let's add a new command (green plus sign):

And in the properties of the new command we will indicate the name “OutputAllEmployees”:

In its properties, click on the magnifying glass next to the “Action” field to set the command handler. Select the option to create a handler "On Client" and click "OK":

We were transferred to the form module in the handler procedure of the "Output All Employees" command:

Writing the command handler code

Now our task is to write code in the internal 1C language that will iterate through all the elements of the “Employees” directory.

I want to say right away that this code cannot be written directly in the “Output All Employees” procedure, since it is executed on the client (pay attention to the special line before the “&OnClient” procedure). Trying to read data from the database in a client procedure will always result in an error (just remember this for now).

Therefore, let's add a procedure like this at the end of the module:

Please note that before it I indicated the “&OnServer” attribute. This means that it will be executed on the server, which means we can read directory data from it.

Now let’s organize a call to this procedure from the client “OutputAllEmployees”:

Here the logic is like this:

  1. The user calls the “Output All Employees” command (for example, by clicking on a button, which we really don’t have yet)
  2. The command launches the handler procedure of the same name “Output All Employees” on the client (after all, the button, and therefore the command, is on the client)
  3. The client procedure "OutputAllEmployees" makes a call to the server procedure "OutputAllEmployeesOnServer"
  4. The server procedure "Output AllEmployeesOnServer" reads directory data from the database and displays them in the message window

All we have left is to write the code for the “Output All Employees on Server” procedure, which goes through the elements of the “Employees” directory and displays them in the message window.

It's actually not difficult. Traversing all directories in 1C is the same. This means that having learned to do this now with the “Employees” directory, you can do the same with any other directories.

To access directory data, a manager is used, which is accessed as follows:

Manager = Directories. Employees;

In this sentence, the key part is to the right of the equal sign. On the left is just a variable into which we save the manager to work with it further. The name of this variable could be not only “Manager”, but also any other - even “Drummer”.

What is a directory manager? A manager is not the directory data itself. A manager is a program object (you can think of it as a black box) through which we can do something with the directory.

The directory manager is like a layer between our code and the directory data. And it turns out that if we need to read all the elements of the directory, we cannot do this directly. We can only ask our layer between us and the directory, that is, the manager, about this.

To do this, you need to call the “Select” method built into the manager. It is called with a dot after the name of the variable in which the manager is stored, and returns a collection of directory elements:

Manager = Directories. Employees; Sample = Manager. Choose() ;

What is a sample? A selection (again, this is just the name of the variable into which we save the result of the “Select” method and it could be anything else) is a collection, but not the same as, for example, an array or a list of values.

The selection is an object - again think of it as a box - but not yet the data itself. The peculiarity of this object is that it can iterate through the elements of the directory we need. Moreover, it sorts them out dynamically. This means that using sampling does not read all the directory elements at once, but selects them in portions from the database.

This approach allows you to quickly traverse large lists of directories using selection, without loading them all into the computer memory at once.

To get the next piece of data from a selection, you need to call the “Next” method built into the selection. Receiving chunks of data (one chunk corresponds to one directory element) usually occurs in a loop:

When the data (directory elements) in the selection runs out, the “Next” method will return False and the cycle will stop.

After each call to the “Next” method (provided that it returned “True”), the selection will contain all the fields with data of only the read directory element, which can be accessed by name separated by a dot:

It turns out in one moment - we work with the data of only one of the elements of the directory. And here we can either immediately display them to the user (using the “Notify” method) or, for example, we can put them in another collection (array) so that we can do something with them at once. It all depends on the problem we are solving.

In 1C there are many configuration objects that are in one way or another connected with accounting - that is, they allow it to be maintained - directories, documents, registers, and so on. However, what to do when you need to create a program in the 1C language that has nothing to do with accounting, but is required for the programmer’s official needs or to make the user’s work easier?

A great example is batch processing of documents. This is a tool that allows you to hold/change/print not just one document, but many at once, according to a selected list. Agree - very convenient.

To implement tools in 1C to facilitate the work of a user or administrator of a 1C database, there is a special configuration object - 1C processing. 1C processing can be part of the configuration or distributed as separate files (then the processing is called external 1C processing).

1C processing allows you to develop your own tools both for 1C programming and for setting up or managing 1C. Thanks to this, there are hundreds of standard treatments on the Internet (developed by 1C) and thousands of amateur treatments on the Internet.

It's time to try doing 1C processing yourself. Details below.

What are 1C processing and how are they used?

A small introduction. Those who are already familiar with 1C processing can skip this point.

So processing is a tool written by a programmer. It cannot do anything on its own and does not save data to the 1C database, unlike, for example, a document - which is saved to the database and can be independently recorded and processed, without additional programming. 1C processing functions depend entirely on the programmer who wrote it.

Based on functionality, 1C processing can be divided into three types:

  • Auxiliary processing of 1C configuration
    Each typical configuration has many treatments. They are used as additional interface forms (user desktop, configuration overview), as part of the configuration functionality (entering initial balances, initial filling of the database, closing the month).
  • Objects (Classes)
    Anyone who knows other programming languages ​​is already familiar with the concept of object. This is a certain class that has at its disposal a set of “variables” and “functions”. Its beauty lies in its self-sufficiency - that is, everything that is needed to perform its functions is collected in one class.

    In 1C, classes can be created using 1C processing: “variables” - 1C processing details, “functions” - functions in the 1C processing object module (Export mark for public functions). The convenience lies in both creating an instance of such a class and moving it between configurations.

    A good example is the processing of 1C printing (additional printed forms), which you can find in standard configurations in the directory Additional printed forms. They always have a public Print() function and standardized usage.

    Please note that, of course, such "classes" are not directly associated with data - they need to be passed or read in the "constructor".

  • Additional user and admin tools
    There are many generic tools available for use by a typical DBA that are not tied to a specific configuration. Such tools are often not included in the standard configuration package and are distributed separately (usually on ITS disks). In addition to standard ones, programmers post a lot of their own tools on the Internet.

    Examples include: 1C processing of work with commercial equipment, 1C task console (displays a list of tasks running on a schedule), 1C query console (allows you to execute any queries without programming), etc.

Where are 1C processing located?

So, there are 1C processing built into the configuration and external 1C processing.

Built-in 1C processing is used situationally by the programmer developing the configuration - that is, they can either be displayed in the user menu (part of the Service menu), or opened programmatically from other 1C objects (for example, from a directory form).

One way or another, under administrator rights, you can open a list of processors built into configurations and any of them, if it can be opened (that is, if it has a screen form and the programmer has not set a lock on opening). To do this, use the Operations/Processing menu in the thick client; use the All functions/Processing menu in the thin client. If you don't know how to find these menus - .

In the configurator, 1C processing built into the configuration is located in the Processing branch.

External 1C processing is opened both in the configurator and in Enterprise using the File/Open menu.

Safety. Please note. The 1C processing object module is executed automatically when you open 1C processing in Enterprise mode. Therefore, if you open a processing written by an attacker, it can be performed automatically without any questions.

How to do 1C processing yourself

So, let's get to the fun part - the algorithm for creating 1C processing yourself from scratch.

Processing 1C 8.3— configuration objects used to change and transform information in the database.

Let's look at how to create it, its properties, how it differs from a report, how external processing differs from internal processing.

There are no special features to note in the creation of the treatment. All functionality is individual and is provided by the developer of 1C 8.3 or 8.2.

Processing has its own details, which store values ​​in RAM for the duration of the “life” of the object. Or, if desired, the values ​​of the details can be saved in .

Get 267 video lessons on 1C for free:

One of the nice features of the processing is its availability when connecting an external connection. That is, when connecting to 1C, you can programmatically create an object, fill in the details and call the export procedure from the module. A typical example for this is data exchange in mode: an external source connects to the database, fills in the settings - object details and activates the download/upload procedure. Sample code:

Object = Processes. UniversalXML Data Exchange. Create() ; Object. Options = Options; Object. Perform Upload() ;

Creating external printed forms under the controlled 1C 8.3 application: