1c general command ordinary forms. Object construction commands. Global commands and local form commands

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

Login to the site as a student

Log in as a student to access school materials

Creating 1C configurations: adding a command

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

Let's return to the configurator and open the configuration tree:

Where is the processing form located?

Let's open the processing settings window "Deleting Fired Employees":

A window opened with bookmarks largely repeating the bookmarks from the “Employees” directory. This is completely normal, because the object settings in the configurator are largely similar to each other.

This time we are interested in the “Forms” tab - open it:

Find on this tab an object named “Form” - this is our visual representation of processing:

Let's open it by double clicking:

A window with many panels opened. And now it is very important for us to understand for future lessons what is responsible for what here.

Changing the code in the built-in 1C language for the form

Well, first of all, let’s pay attention to the very bottom of the window that opens. There we will find two tabs “Form” and “Module”.

The "Form" tab is a visual representation. Currently there is only one button on the form: “Delete employees”.

The "Module" tab is a code in the built-in 1C language that contains procedures and functions that determine the behavior of the form for the user.

Let's try switching to the "Module" tab:

There is only one procedure named “DeleteEmployees”. Obviously, this is what is called when the button is pressed.

The procedure code is now collapsed - click on the plus sign to expand it (it doesn’t fit in the picture on the right):

That's right, that's right. This is the place where a message appears stating that I did not write the code for this processing

Let's change this code as follows:

Let's start the 1C:Enterprise mode again (menu "Debug" -> "Start debugging"), open processing and click the "Delete employees" button:

And we will receive the same message that we just wrote:

The "Elements" tab of the form

Let's return to the configurator to our form on the "Form" tab:

Pay attention to the "Elements" tab at the top of the form. The content of this bookmark duplicates the visual representation of the form. You are reading a trial version of the lesson, full lessons are available. We can also say that everything that you see in the visual part of the form can be found on the “Elements” tab.

For example, to open the properties of the “Delete employees” button on the form, find this button on the “Elements” tab and double-click on it:

A window with the button properties will open:

Let's set the title of the button to "BANG":

The form will now look like this:

The "Details" tab of the form

Now let's move on to the "Details" tab:

This tab contains names by which we can “reach” the object data that the form represents. You are reading a trial version of the lesson, full lessons are available. So far there is only one attribute “Object” on this tab, and it’s empty.

But if we went to a similar tab in the form of the “Employees” directory, we would find here the details “Date of Birth”, “Passport Number” and “Passport Series”. This would mean that we could use them in the form module code.

The "Commands" tab for the form

The final tab we'll look at today is the "Commands" tab:

In general, all the commands that you see on one of the tabs ("Form Commands", "Standard Commands" and "Global Commands") can be safely dragged to the "Elements" tab and they will "magically" turn into buttons on the form.

As you understand, clicking on these buttons will lead to the execution of these commands.

Well, for example, let's go to the "Standard Commands" tab and drag the "Close" command to the "Elements" tab:

A close button appears on the form. Let's launch 1C:Enterprise (menu "Debug" -> "Start debugging"), open processing and make sure that the button works:


Let's return to the configurator to the processing form and go to the "Form Commands" tab:

On this tab we see the form commands that we have defined ourselves. Among other things, we can see here the command that I defined at the very beginning with the name “DeleteEmployees”.

Open the properties of this command (double-click) .

We are primarily interested in the “Action” field; click on the button with a magnifying glass next to it:

We were taken to the “DeleteEmployees” procedure in the form module. This means this command and this procedure are related. And executing the command (for example, when you click on the button it turned into) will lead to the execution of the procedure code.

Adding a new command for the form

Let's create another form command. To do this, go back to the “Form Commands” tab and click the green button with a plus:

Open its properties and set the name to “Hello”, and then click on the magnifying glass next to the “Action” field:

We are asked what kind of handler we want to create.

In general, there are two types of handlers - those that run on the client and those that run on the server. In our case, the client and server are the same computer, but this is not necessarily always the case. We will return to this conversation in future modules, but for now it is too early for us to think about it.

Select the “On Client” option and click “OK”:

We were taken to the form module in the automatically created "Hello" procedure. This procedure is now linked to the "Hello" form command:

Let's write in it the output of the line hello to the user:

But how can we now force the command (and therefore the procedure) “Hello” to be executed? To do this, return to the “Form Commands” tab and drag our “Hello” onto the form, as we did earlier with the “Close” command:

Another button has appeared on the form. Let's launch 1C:Enterprise, open processing and click on the "Hello" button. It should look like this:

Enter the user's name and say hello to him

Now let's set ourselves this task. We need the user to enter his name, we click on the button and it will display, for example, “Hello, Alexey”.

In order for us to place elements for data entry on the form, we will need a form attribute (the "Details" tab) with which this element will be associated.
Since our “Details” tab is almost empty, let’s create a new one.

Go to the “Details” tab and press the green plus button:

In the properties window of this attribute, set the name to “Name” and the type to “String”:

After this, let’s drag the “Name” attribute to the “Elements” tab in the usual way:

Aha, an element for entering a string has appeared on the form! What we needed

Let's launch 1C:Enterprise, open processing and try to enter your name there:

Everything worked out, but clicking on the “Hello” button still works as before.

We'll fix everything now. You are reading a trial version of the lesson, full lessons are available. To do this, let’s return to the configurator, go to the processing form module and find the “Hello” procedure there:

Let's rewrite it in such a way that the value of the "Name" attribute, which is associated with the input element on the form, is added to the line "Hello,"

Now let’s launch 1C:Enterprise processing again, enter your name and click the “Hello” button:

Just what you need!

Commands, elements, details, object... aren't you confused yet?

I think you are confused. I hasten to reassure you that you should not worry about this. Over time, the situation will become clearer.

In the meantime, I will try to describe to you in simpler words these components of any form. And after that you can re-read the lesson again - I’m sure a lot will become clearer.

So, a form is a visual representation of our program: buttons, labels, pictures, lists... and a lot of things! All this ELEMENTS forms.

Button - element. The inscription is an element. The input field is also an element

That is, a form element is, first of all, part of its visual representation. This means that the element has such characteristics as color, font, position on the form, size and many others.

Elements allow us to interact with the form in some way: read, click, scroll, etc.

For example.

Button

Obviously, the button cannot be on its own. When the user clicks on it, some action intended by the programmer should occur.

This action is called team

Commands can be built-in (the “Standard Commands” and “Global Commands” tabs) and those that the programmer comes up with himself (the “Form Commands” tab).

Well, built-in commands are built-in for that reason. That their action was invented before us. All we can do is drag these commands onto the form and turn them into buttons. Such commands include, for example, the command to close a form. We don't need to program anything - just drag the standard "Close" command onto the form and that's it

And the uniform team is a team invented by us ourselves. This is the command that we ourselves added to the “Form Commands” tab, then found the “Action” item in its properties, clicked on it and programmed the code in the built-in language in an automatically created handler in the form module (for example, the “Hello” command from this lesson).

Well, in general, you understand: a command is some action programmed in the 1C language (or already built into the program). A button is a visual element of a form that, when pressed, launches an associated command.

Inscription

It's just text on a form. Such an element has a “Title” property, the value of which we set in the editor and it is displayed as text.

Field

Now this is interesting. Because this is such a special element that is not in itself (like an inscription), but must be associated with some kind of data or in another way DETAILS(tab "Details").

It can be said that props is a variable form, which we declare on the “Details” tab, and the element associated with the attribute (“Field”) is its representation on the form. But the props themselves only have Name, type And meaning.

Well, imagine that we have a field on the form for entering a number. If there were no details, how would we know from the code what number the user entered? We would access the input element by name and read some of its properties, which are responsible for the value entered by the user.

So in 1C this is not possible. Here (starting with “managed” forms) the presentation of data is separated from the data itself.

It turns out that the input element is a form element. And the number that the user enters is stored not in the element itself, but in the attribute that is associated with this element.

Again. A prop is exactly data (string, number, date). Non-visual representation (inscription with text, field for entering a number, field for entering a date). The visual representation of the props is precisely the “Field” form element.

And it turns out that when writing code in the 1C language, to display and change data, we must first of all use details. We change the details from the code, and the fields associated with them on the form change automatically.

And vice versa. The user enters values ​​into the input elements (numbers, text, dates) on the form, and the details of the details also change automatically.

What advantages does this separation of form elements from data (details) provide? Big ones! The programmer creates the details he needs (for storing, displaying and entering some fields on the form) and writes program code working only with these details (data). He doesn’t think at all about how it will all look on the form. He doesn't need it! He only writes program code for now.

And only then he drags these details onto the form, the details turn into visual elements of the form, he somehow configures them, stuffs them into bookmarks and so on. In general, at this stage (visual design of the form), he works only with elements. At the same time, the likelihood of breaking already written code is greatly reduced.

Another example. Let us have an attribute "Age" with a type of "Number". This attribute stores only the number itself, nothing else. It is not responsible for what this number will look like, and in what place (or on what tab) the input element on the form associated with this number will be located. Props are just a number! Turning to the props, we will not be able to change the size of the input element on the form, color, visibility... It is not the props that are responsible for all this, but the element! By changing the details, we only change the number that is displayed in the input element on the form.

All in all: PROPS is a form variable. Therefore, we store all data in details (variables), and use elements to display them on the form (or input from the form). It is this separation of logic from presentation that allows 1C to easily display the same forms on different clients: “thick”, “thin”, “web browser”.

To access the “Age” attribute from the form module, just use its name:

What is an Object?

And finally, the object. Judging by the fact that it is on the “Details” tab, this is also a prop. That's right. But he is special.

We do not create this attribute - it appears on the “Details” tab. In the case of processing, it is empty, but if we were programming the form of some directory, then the object attribute would precisely represent the fields of this directory from the database.

A plus sign would appear next to it and we could open it and drag its individual parts onto the form and they would also turn into elements.

Take the test

Start test

1. The processing form may contain

2. The processing form is on the tab

When several objects are simultaneously selected, buttons with the following object formation commands appear on the property panel:

ü Weld(An association). Allows you to create a new shape by combining two or more overlapping objects. The original objects are automatically deleted. To fill the new object, use the fill of the top object.

ü Trim(Exception). The part of an object that overlaps another object is removed. The original objects are deleted

ü Intersect(Intersection). Creates a new object formed from the overlapping area of ​​objects. The original objects are preserved.

ü Simplify(Simplification). Allows you to delete all invisible parts covered by other objects.

ü Front Minus Back(Delete by background). As a result of executing the command, that part of the top figure remains that did not overlap anything.

ü Back Minus Front(Remove by foreground). As a result of executing the command, that part of the lower figure remains that was not blocked by anything.

More full control Shape formation can be done using docker Shaping(Formation). Here you can additionally set options for saving source or target objects after executing the command.

ü if the checkbox is checked Source Objects(Initial objects), then after the command is executed, the object that was selected before the command was selected will remain;

ü when checking the box Target Object(s) (Target objects) the object to which the Exclude, Union or Intersect command was applied will remain.

Knife Tool

Located in the toolbox on the same button as the tool. Used to divide an object into several parts. The cut line can be either strictly straight or free form. The start and end points must be close to the edge of the object. In the tool properties panel you can configure:

ü Auto Close On Cut(Auto-lock after cut). After cutting, the parts of the object become independent objects.

Eraser Tool

With it, you can interactively erase individual areas. The tool is located in the toolbox on the same button as the tool Shape(Form). In the properties panel you can configure:

ü Erase Thickness(Eraser Width) 0.001 to 100 inches

ü Auto reduced On Erase(Reducing the number of nodes after erasing) - reduces the complexity of the figure after erasing its individual fragments by reducing the number of nodes in the erased area

ü Circle/Square(Eraser shape) can be round or square

Smudge Tool

Allows you to change the outlines of shapes so that they appear to be smeared. The stroke changes according to the specified tool parameters.

ü Nb Size (Tip thickness). Default is 0.1 inch. Range from 0.03 to 2 inches.

ü Using a pen with pressure. Used when working with a graphics tablet.

ü Add Dryout to the effect(Intensity). Specifies a gradual change in stroke size based on the speed at which you drag the mouse pointer. Range from -10 to 10. At value 0 the effect is not observed.

ü Fixed value for title setting(Roundness of the tip). Controls the shape of the stroke. Measured in degrees. Can range from 15 (flat tip) to 90 (elliptical tip).

ü Fixed value for clearing setting(Rotate the stroke). The stroke is positioned at a given angle.

Practical work

Exercise Using object generation commands

1. Draw some objects. Arrange them like this. so that they overlap each other.

2. Open docker Shaping (Windows‑Docker‑Shaping or Arrange‑Shaping)/

3. From the drop-down list at the top of the Shaping window, select Weld.

4. Select one of the overlapping objects - it will be the source for executing the command

5. In the Shaping docker, in the Leave Original group, select which objects should remain after the command is executed - the source, target, or both. To execute the command, click the Apply button (at the bottom of docker). The mouse pointer will take the form of a bold arrow.

6. Click on the target object (the one with which the source object should interact). You have formed a new object from several overlapping simple objects.

Repeat steps 1-6 for the Trim and Intersect commands.

Exercise Using the Knife Tool

1. Create an object on the document page and select the Knife tool from the toolbox.

2. Move the tool pointer to the edge of the object (it should take a vertical position), click the mouse and move it to any point on the edge of the object and click the mouse again. This way you get a straight cut and divide the object into two separate shapes.

3. Create another object. To cut it along an arbitrary path, after the first click on the border of the object, drag the tool pointer to another point on the border along an arbitrary path; when you reach the border, release the mouse button

At the start and end points of the cut, the tool pointer must be in a vertical position!

Exercise Using the Eraser Tool

1. Create an object on the document page and select it with the tool Pick(Choice).

2. Select the Eraser tool from the toolbox. Mentally identify the area of ​​the shape you want to remove. In the properties panel, set the shape and width of the tool.

3. Position the pointer at the selected location and double-click. A fragment of the object that matches the shape and width of the eraser will be deleted.

4. Now erase part of the object by dragging the pointer randomly inside the object. As soon as the mouse button is released, the deletion process is completed.

5. To delete a straight fragment, you can click the pointer first at the starting point, and then at the end point of the line.

6. To erase a broken line with a tool Erase The following sequence of actions is used:

ü Click the starting point of the polyline and move the mouse pointer to the next node (a dotted line will follow it), reaching the node - press the Tab key

ü then move the pointer to the next node and press the Tab key again to delete the line along the path of movement and so on until you delete the required fragment of the line or the entire line;

ü at the end of the procedure, press the left mouse button - erasing will end.

Exercise 4 Using the Smudge Tool

1. Create or select a shape to which the tool will be applied Smudge. If it is a dynamic figure (rectangle, polygon, ellipse, etc.). then turn its contour into curves Ctrl+Q.

2. Select a tool Smudge. In the toolbar, set the brush thickness and other properties.

3. To start smearing, drag the tool pointer Smudge through the outline of the figure. Please note that each time the contour is crossed, it changes its shape in accordance with the set parameters. The “smearing” process can continue as long as desired until the desired effect is achieved.

Arranging objects

Grouping commands

When more than one object is selected at the same time, the following commands appear in the property bar to group objects:

Group(grouped objects are highlighted as one) - button Group in the properties panel is available in case of simultaneous selection of two or more objects, the command Group from the context menu or keyboard shortcut<Ctrl+G>. The group behaves as a single object, i.e. any changes made to a group apply to all objects within the group. Each group object is called a child object. An object in a group is selected with the tool Pick with the key held down<CTRL>. Only one object in a group can be selected at a time.

Three or more objects, then:

    run the command " Format > Align/Distribute > <вариант действия>» main menu;

    run the command " Align/Distribute > <вариант действия>» context menu;

    On the “Alignment” toolbar, click the button corresponding to the required action.

The following object alignment/distribution options are available:

    Align Left. The selected objects will be left aligned relative to the leftmost object:

    Align Center. The selected objects will be centered. The center is calculated based on the position of the leftmost object and the rightmost one among the selected objects and the size of the objects themselves:

    Align Right. The selected objects will be right-aligned relative to the rightmost object:

    Align to top edge. The selected objects will be top-aligned relative to the topmost object:

    Align to Middle. The selected objects will be aligned to the middle. The middle is calculated based on the position of the topmost object and the bottommost object among the selected ones and the sizes of the objects themselves:

    Align Bottom Edge. The selected objects will be bottom-aligned relative to the bottommost object:

    Distribute horizontally. The selected objects will be at the same distance from each other. The distance is calculated based on the position of the leftmost object and the rightmost one among the selected objects and the size of the objects themselves:

    Distribute vertically. The selected objects will be at the same distance from each other. The distance is calculated similarly to the previous paragraph:

The 1C form usually has several fields for entering data, as well as buttons for form control and various service actions. For example, for automatic filling or verification.

In order to place a button on a form, earlier, in version 8.1, you had to:

  • Drag a button to the panel
  • Add a function - buttons
  • In this function, write code in 1C language that will perform the required actions.

In order for the user to launch them, these actions have a visual representation on the form. What it will be depends on which group of form elements you drag the command into.

For example, if you simply drag it onto a form, there will be a button, if into a command panel group, then it will be a command panel button (flat), or you can drag it to a menu, then it will be a menu item.

The command can be used both on a regular form and in the managed (command) 1C interface.

Standard 1C commands

But we also know actions that do not need to be programmed in the 1C language, since they are already available in the 1C platform. For example, for directories, standard actions are the ability to create an element. For the directory form - the ability to write, and for a document - to post. Are these also actions?

Yes, and now they are called standard 1C commands. Directories, documents, forms and others have their own standard 1C commands.

Standard 1C commands can be disabled for a specific one by checking the “Use standard 1C commands” checkbox in 1C on the “1C Commands” tab.

1C team owner

1C commands are located in the sub-branch of their owner. For example, Directories/Counterparties/1C Teams.

There are also 1C teams that do not have an owner, since they are shared. Such 1C commands are not tied to objects and are located in the General/General 1C commands branch.

1C command parameters

In the configurations in reference books and documents there was a “Go” menu with which you could magically go to related 1C objects.

For example, for the Counterparties directory, the legal and physical addresses are stored in the associated Contact Data register. To go to it, you had to select the menu in the form of the counterparty(s) - Go/Contact details.

That is, for some actions, not only the fact of launching the action is required, but also a parameter that determines for which object these actions need to be performed - for example, for which counterparty to display contact information.

In the properties of the 1C command it is possible to specify:

  • 1C command parameter type – type of 1C object that will be used as a parameter, for example, the Contractors directory
  • Mode of use parameters – you need one value or a list (array).

To place a command on a form, you can specify in the 1C command properties the command interface group where it should be located.

Or simply drag the command to the list of form elements.

Team is a configuration object with which the developer can describe actions intended to be performed by the user.

There are general commands - commands that are not object specific or are used to perform actions on objects that do not use standard commands.

Commands can also exist for individual configuration objects. They are used to perform operations related to this particular object.

Commands can be parameterized, that is, they can use some value passed by the platform in their algorithm. The type of this value is set in the configurator and such a parameterized command is displayed only in those forms that have details of the same type as the command parameter.

The actions performed by a command are described in a built-in language in the command module.

Useful links:

  • Configuration objects
  • Development tools.

Command

Team is an action that the user can perform in the program. All commands can be classified in several ways.

Standard and developer-created commands

In relation to how the command appeared in the configuration, all commands can be divided into:

  • Standard,
  • Created by the developer.

Standard commands are supplied automatically by the platform. Configuration objects, as well as form extensions and element extensions, can supply standard commands Table, located in the form. Read more...

For example, a directory Counterparties can supply commands Counterparties, Contractor: create And Contractors: create a group.

The developer can create arbitrary commands in the configuration himself. He can add a Command object to the branch Are common, add a Command object to a specific configuration object, or describe a command as a procedure in a built-in language in a specific form. Read more...

For example, general commands can be added InstallBarcode Scanner, SetupBarcode Scanner and others.

Navigation and Action Commands

In relation to what is the result of executing a command, all commands can be divided into:

  • Navigation commands,
  • Action commands.

Navigation commands open forms in the current window. As a rule, this is how a transition to some lists is performed. Read more...

For example, the navigation command Warehouses will open a list of warehouses in the main window.

As a result of executing the action command, an auxiliary window opens. As a rule, this is how you go to the object form or to the report/processing form. Read more...

For example, action command Stock will open an auxiliary window for editing the data of the new warehouse.

Independent and parameterizable commands

In relation to their internal structure, all commands can be divided into:

  • Independent,
  • Parameterizable

Independent commands do not require any additional information to execute. Read more...

For example, an independent team Counterparties does not require any additional information for its execution. It simply opens a list of all counterparties.

To execute parameterizable commands, you need Additional Information- value of the command parameter. Read more...

For example, the parameterizable command Current accounts (Object.Supplier) opens a list of current accounts of a specific counterparty. Therefore, to carry it out, you need to know which counterparty’s current accounts need to be opened. That is, the counterparty is a parameter of this command.

Global commands and local form commands

According to the relation of commands to a certain form, all commands can be divided into.