1c display a message in the window. Messages to the user in managed forms (one more time). Messages linked to the attribute of the tabular part of the object

In programs on the 1C:Enterprise platform, a message can be shown to the user in different ways.

1. Method ShowWarning.

ShowWarning(< ОписаниеОповещенияОЗавершении> , < ТекстПредупреждения> , < Таймаут> , < Заголовок> )

When using this design, a warning window appears in the center of the program interface.

Options:

DescriptionComplete Alerts(optional)
Type: DescriptionAlerts. Contains a description of the procedure that will be called after closing the alert window with the following parameters: Additional Parameters - the value that was specified when creating the Alert Description object. If the parameter is not specified, then upon completion no procedure will be called.

TextWarning(required)
Type: String; FormattedString. Warning text.

Timeout (optional)
Type: Number. The time interval in seconds during which the system will wait for a user response. When the interval expires, the warning window will be closed. If the parameter is not specified, then the waiting time is unlimited. If the parameter is negative, an exception will be thrown. Default value: 0.

Title (optional)
Type: String. Contains the title of the warning window. Description: Displays a warning window, but does not wait for it to close.

Availability: Thin client, web client, thick client, mobile application (client).

Note: If any code must be executed after the user closes the warning window, it must be placed in a separate module procedure and described in a parameter.

2. Method Warning.

A warning window appears in the center of the program interface. However, if the configuration property Mode of UseModalities is set to Do Not Use , then the method does not work.

Availability: Thin client, web client, mobile client, thick client, mobile application (client).

3. Method ShowUserAlert.

ShowUserAlert(< Текст> , < ДействиеПриНажатии> , < Пояснение> , < Картинка> , < СтатусОповещенияПользователя> , < КлючУникальности> )

When using this method, a message appears in the lower right corner of the interface.

Availability: Thin client, web client, thick client.

4. Report method.

To report(< ТекстСообщения> , < Статус> )

Availability: Thin client, web client, mobile client, server, thick client, external connection, mobile application (client), mobile application (server).

5. Object Message to User.

Designed to store message parameters that need to be displayed to the user. If the message has not yet been shown to the user (this can happen when working on the server side, in a background job, external connection or Web services), you can get the accumulated messages using the method Receive Messages to User.

Properties: Destination ID(TargetID); DataKey; Field; DataPath(DataPath); Text.

Methods: Message; SetData(SetData).

The message appears at the bottom of the interface, in a line.

Message = New MessageToUser(); Message. Text ="Not enough nomenclature" ; Message. Field =

"Nomenclature. Quantity"

;

Message. SetData(DataObject) ;

Message. To report() ;

  • The article continues the series of articles “First steps in development on 1C”.
  • In it we will look at the methods of informing the user that are present in the 1C:Enterprise platform 8, and also focus your attention on some features of the operation of these mechanisms; these features are related to the mode of use of the modality.
  • Applicability

The article discusses the functionality:

Interface in the “Version 8.2” version for the configuration developed on the 1C:Enterprise platform 8.2.19.130

  • Taxi interface for configuration developed on the 1C:Enterprise platform 8.3.4.496 to 8.3.9+
  • Taxi interface for a configuration developed on the 1C:Enterprise platform 8.3.10-8.3.11
  • How to display a message to the user in 1C

Displaying messages in user mode solves a number of problems:

  • reflection of the progress of the current process (showing the stage of execution of the process; showing the calculated values ​​​​obtained during the operation of the algorithm);
  • displaying errors to the user for possible correction;

issuing recommendations;

Introductory messages are intended to provide the user with some information.

It is necessary that the user familiarize himself with it and, possibly, take some actions that are described in this message.

It is very important that the user actually reads these messages, so they should only contain important information.

Test and debugging messages should not be issued to the user, because sooner or later he will begin to ignore absolutely all messages.

In the concept of a managed interface, the approach to issuing a message has changed somewhat. It is now tied to the form in which it originated. It can no longer be closed so that the text is completely invisible.

You cannot unpin a message box from a form.

Function syntax:

To report (<Текст сообщения>, <Статус>)

Those. the first parameter is the text itself.

The second parameter (message status) is optional. You can specify values ​​for the status: Normal, Important, Very important etc.

This value determines which icon will be located next to the message. However, this only works in the normal interface.

In the managed interface concept, the icon is always an exclamation mark and cannot be overridden.

The fact is that if a message is generated at the time of writing a directory element, the following situation may occur.

User clicks on a button Save and close, in this case the message is displayed in the corresponding window (on the right of the form).

But the form closes instantly, and the user will not see that any information was displayed for him.

Therefore, in the concept of a managed application, it is recommended to display introductory messages using so-called alerts. An example of incorrect use of a function To report presented in the figure.

However, the function To report can be used to display information about certain errors, for example, at the time of document posting.

In this case, the system can be informed that the form does not need to be closed and show the user what errors occur when posting the document.

Function To report fully supported in Platform 8.3. It can be used, and it will work (both in the file version and in the client-server version).

But it should also be noted that the function To report There is a further development - this is a message class for the user, which allows, in addition to displaying a message, to bind it contextually to any form elements.

For example, an error message can be tied to a form element, which is very clear to the user. We will return to consider this issue a little later. Function To report there is an interesting feature.

Thus, the program code in Platform 8.3 can be executed both on the Client side and on the Server side.

In this case, the client program code is responsible for interaction with the user, i.e. On the client side, forms are opened and reports are displayed.

Various dialog documents are also displayed only on the client. They cannot be executed on the server because the server does not have the ability to interact with users.

But the function To report can be executed both on the Client side and on the Server side. In this case, the use of the method To report on the Server does not mean at all that the message will be displayed on the Server, there is simply nowhere to display them.

This means that if we display a message in the server procedure using this method, they will accumulate in some buffer and they will be displayed on the screen only when the server procedure ends and returns to the Client.

At this point, the system will request data from the buffer and display it on the screen.

The same feature applies to the class Message to User. The figure shows an example of using the method To report on the Server side.

As a result of using the method To report on the Server side, messages were displayed on the screen on the Client side.

An alert mechanism is needed to inform the user that “something” has happened in the system and that “something” requires the user’s attention. Alerts are generated by two scenarios:

  1. By the platform itself when interactively recording or changing an object
  2. By the developer when calling a method in the code .

The notification itself is a small window that appears, as a rule, in the lower right corner and informs about the completed action. Within a few seconds it gradually fades and disappears. At the same time, if you hover your mouse cursor over the notification, it does not go away and you can read it carefully.

In addition, notifications can be accessed in the corresponding area of ​​the information panel (the “History” button at the bottom left of the application form in the “Version 8.2” interface option).

To create your own alerts, you must use the global context method ShowUserAlert(). Its syntax before version 8.3.10 is presented below:

ShowUser Alert (<Текст>, <НавигационнаяССылка>, <Пояснение>, <Картинка>)

The first parameter contains the text that will be displayed in the notification.

Then, as the second parameter, you can pass a certain navigation link to any element of the information base (the element that corresponds to the text of our message). When a user clicks on an alert, the link will be followed.

Using the third parameter, you can pass an explanation for the message, i.e. some extended description.

You can also assign a picture that displays the notification status.

It should be noted that all these parameters are optional. Below is an example of using this method (in the configurator and in user mode in the “Version 8.2” interface option).

In the version of the platform 8.3.10.216 for the “Taxi” interface, the notification mechanism was significantly improved in order to improve the usability of both the thin and web clients. For this reason, the parameters passed to the method have also changed ShowUserAlert(). Now the syntax looks like this:

ShowUserAlert(<Текст>, <ДействиеПриНажатии>, <Пояснение>, <Картинка>, <СтатусОповещенияПользователя>, <КлючУникальности>)

It can be seen that the second parameter, previously called Navigational Link, got a new name ActionWhenClicked. This is due to the fact that it is now possible to send not only a string with a navigation link, but also a description of the alert. This is illustrated in the screenshot below:

As can be seen from the example, we now have the ability to programmatically process a click on a notification window, according to the logic that is necessary.

Next parameter User Alert Status appeared for the first time. It indicates the status of the alert (Information or Important).

In the case of the Important option, if the user has not responded to the message, then after it is hidden from the screen, it can be read through the Notification Center (more about it below). In the case of the Information option, the notification is deleted without being stored in this center. Let's rewrite the code from our example as below:

After executing the command, we get approximately this view of the application window:

A button with a bell icon has appeared in the toolbar, which calls up the above-mentioned Notification Center. It accumulates new important alerts to which the user has not yet responded.

If there are any alerts in the Center, a small orange dot appears next to it to attract the user's attention. The user can open the Notification Center, read the text and, if necessary, take some actions.

From the Center, the alert is cleared by clicking on the clear button, but if there is some action associated with the alert, then as soon as the user clicks on the text of the message, it will also disappear.

And finally, the last parameter added was Key of Uniqueness. You can use it to find the alert displayed on the screen and change it. If there is no alert with this parameter, a new alert will be shown.

As you can see, the possibilities provided by the corresponding method have become even greater! But these are not all the changes in the notification mechanism.

As you may have already noticed, their appearance has changed. Alerts now look more modern and ergonomic, but they cannot be moved around the screen or resized. Please note that in our example, the notification text simply did not fit entirely in the window itself, and the user will be able to read it in full only by opening the Notification Center. Therefore, you should not write a large amount of text in the notification text.

New features also include the simultaneous display of up to three alerts on the screen.

This concludes our acquaintance with the software generation of alerts. However, remember that alerts are generated not only by the developer programmatically, but also by the platform itself at the time of interactive recording or changing an object. And often this fact causes misunderstanding primarily among novice users: why are these service alerts needed, which, by the way, cannot be turned off?

Let's imagine this simple situation: the user has set a filter in some list for convenience. Let's say he did this in the form of a list in the Nomenclature directory. Then, after some time, I decided to introduce a new element called “Chair”, which does not correspond to the previously installed filter. Enters it, writes it down and...? And he doesn't see it on the list. What will the average user do? Of course, he will enter it a second time, but will not see it again. This may be followed by a third, fourth, fifth time. When he gets tired of entering the same thing over and over again, he will finally ask you: where does everything go?

This is precisely why the platform displays these service alerts, informing the user that their action has been completed. In our example, at the time of interactive recording, the user will see the following notification:

Termination messages

Termination messages are those messages that will not allow work until the user performs certain actions, i.e. until it processes the message.

We will talk about the possibility of using termination messages in Platform 8.3 a little later (lately they have been trying not to use them, so the example considered is more relevant to Platform 8.2).

There are two methods for issuing termination messages Warning And Question. Warning differs from Question because it has a single button OK.

A question may specify different sets of answer options ( Not really, YesNoCancel, OK, OKCancel, RepeatCancel, AbortRepeatSkip), which are specified using the parameter.

Let's display some warning using the line (for example, in a managed application module):

Warning(“The base will now be open”);

To open a managed application module, select the object in the configuration tree Configuration, call the context menu and select the item Open a managed application module.

In this case, when the application is launched, a window will be displayed that is modal. A modal window overlaps all windows that exist in the application. Until we process this window, no further actions are possible.

The function works in a similar way Question.

Syntax:
Question(<ТекстВопроса>,<Кнопки>,<Таймаут>,<КнопкаПоУмолчанию>,<Заголовок>,
<КнопкаТаймаута>);

Only the first two parameters are required. For the second parameter, the data type is composite ( Dialogue ModeQuestion or ListValues). Third parameter ( <Таймаут> ) characterizes the time interval in seconds during which the system will wait for a user response.

When the interval expires, the question window will be closed. Similar parameter( <Таймаут> ) is also present in the function Warning.

As an example of using the function Question You can use the following code, written in a managed application module:

Please note that these methods ( Warning And Question) are not available on the Server. And this is logical, because interface methods cannot be executed on a Server where there is no user.

Features of using modal windows in Platform 8.3

In platform 8.3, there are operating modes with and without modality. The default setting is Do not use modality mode.

In this case, the use of termination messages is impossible. If it is necessary to use termination messages (functions Warning And Question) you should change the value of the configuration property on Use.

The modal window is displayed at the very top and blocks work with other windows until the actions with the modal window are completed. In addition, the execution of the program code stops at the point where this window is called. Code execution will continue only after the modal window is closed.

Firstly, problems with using modal windows arise for a mobile application. Secondly, in the browser, window modality is implemented using separate pop-up windows.

Pop-up windows are often disabled by default browser settings. The user has to be forced to set the permission for these windows.

Browsers for tablet computers and phones in most cases do not support pop-up windows at all.

To replace functions Question And Warning new methods have been developed: ShowQuestion, ShowWarning.

These methods allow you to call a window, but do not stop the execution of the program code. Technically, this is achieved by forming a pseudo-window inside the parent window. The pseudo-window does not overlap the parent window. After opening such a window, the code continues to execute.

Receiving and processing user-entered values ​​is carried out in a separate procedure, which is called when the dialog box is closed.

Function syntax ShowWarning:

ShowWarning(<ОписаниеОповещенияОЗавершении>, <ТекстПредупреждения>, <Таймаут>, <Заголовок>)

Parameter <ОписаниеОповещенияОЗавершении> (optional)

Data type: DescriptionAlerts.

Contains a description of the procedure that will be called after the warning window is closed.

Function syntax ShowQuestion:

ShowQuestion(<ОписаниеОповещенияОЗавершении>, <ТекстВопроса>, <Кнопки>, <Таймаут>, <КнопкаПоУмолчанию>, <Заголовок>, <КнопкаТаймаута>)

The first three parameters are required.

Below is an example of using the function.

Class MessageToUser

Basic convenience of the message class Message to User is that this is a contextual message (unlike methods Warning And Question).

Messages can be tied to a specific screen element. This object is also available on the Server.

Please note that, firstly, this object must be created. For example: Message = New MessageToUser;

Thus we create an instance of this object.

Secondly, you need to specify the message text in a separate property.

Thirdly, in the property Field You can specify which form element this message should be attached to.

Attention! To bind to the desired form field, pay attention to the initialization of properties PathToData And DataKey. For a document, when placing code in an object module, you can write:

Message.DataPath = “Object”;
Message.DataKey = ThisObject.Link;

To open the document module, in the object (document) editing window, go to the tab Other press the button Object module.

For the experiment, we will place the code in the object module of a document.

Below is the result obtained in user mode for Platform 8.3.

It should be noted that messages output using the new system object Message to User in the general case they are not terminating. Those. the system will allow the user to continue further actions without responding to the displayed messages.

But, firstly, these messages are quite noticeable. Secondly, messages are usually displayed to the user at the time of recording elements of directories or processing documents, i.e., when some checks are performed. And if errors were detected, the user will see these same messages.

Accordingly, when errors are detected, the transaction is canceled, i.e. writing a directory element is prohibited, or posting a document is prohibited.

Thus, a kind of emulation of the termination message occurs. Because the action is canceled until the user reacts to the entered message, it will be impossible to complete the action, for example, posting a document.

But, on the other hand, it is possible to close the document without conducting it, without reacting to the message in any way. Therefore, these messages to the user are not terminating.

Process status notification

There is a special function with which you can display the approximate progress of a process.

Syntax: State(<ТекстСообщения>, <Прогресс>, <Пояснение>, <Картинка>)
Options:<ТекстСообщения>And<Пояснение>– optional, type – Line.
The text is displayed on a special status bar.
<Прогресс>The parameter is also optional, but visual.
Type: Number. Progress indicator value (from 1 to 100).
<Картинка>also an optional parameter.
When processing any event, periodic calls of a function like:

In this case, the labels may change, and the values ​​of the Progress parameter may change.

A function can be called from one procedure (function) or from several. This way you can track the execution status of the process.

If you want to take a closer look at the notification mechanism, stop right now and read our new article, Displaying the progress of long-running operations in 8.3.10. It explains, no longer at the level of a beginner, all the subtleties and pitfalls of the operation of this mechanism.

We are finishing our introduction to ways to inform the user. We hope that you have an understanding of in what situations one or another method should be used.

I would like to once again draw your attention to the fact that if your configuration (version 8.3.3+) involves working using a web client, then:

  • at the configuration level the modality mode setting must be set to “Do not use”
  • The code must use methods of the asynchronous user interaction model. Such methods begin with the words Show or Begin.

You can read more about refusing to use modal windows in the 1C:Enterprise 8.3 platform in the final article of the series. And we move on and, finally, begin to study the long-awaited Taxi interface, which has already been mentioned more than once in our materials.

Good afternoon.

Today we will talk about such a simple thing as messages to the user.

IN 1C 8 method migrated from 7.7 - " To report(...)". This method is very simple, it opens a message window if it is not open, and adds the text of the message there. As in 1C 7.7, it has a second parameter that defines the icon opposite the message. This icon determines the importance of the message.

As time went on, we got controllable forms in our hands. Managed forms do not have a single message box. However the method is still supported. In the new interface, messages stick to the active window. When I switch to another window, the messages disappear from view, but when I return, they appear again. In some cases this is not convenient, but there is nothing you can do about it; a managed form implies the absence of a main window to which messages could be attached.

However, since the message is associated with a specific form, this allows platform authors to expand the functionality of a simple message. You may have already seen in standard configurations that messages are now integrative, clicking on a message positions us on a specific field, double clicking can open some other element of the database.

The fact is that it is now customary to use not the global context method "Report(...)", but the object " Message to User". This object is available everywhere, both on the client and on the server. It has several properties and a couple of methods.

In general, if you need to give the user just a message, without any interaction, then just write:



Message.Message();

These three lines are absolutely identical to the method we already know, and therefore using this object for such a message is pointless.

The main fields that expand the capabilities of the message are:

  • DataKey
  • Field

Data key- a link to the infobase object to which this message relates, or a record key. That's what it says in the certificate. If we insert a link to a document or reference book here, then double-clicking will open this object, regardless of the form in which the message was displayed. Accordingly, if the message appears in the form of a document, and the data key contains a link to it, then the new form will not open.

Nonsense can happen if we issue a message in the form of an object that has not yet been written down. In this case we have an empty link. But the platform is not lost, and simply does not open anything, i.e. You remain in the form you were.

Field- this is a line with the name of the field that needs to be activated. And it doesn’t matter whether the form of another object opens or we remain in the current form.

Here's an example of how it works:

Suppose, before writing a directory element in the form module, we check the uniqueness of the “Id” attribute and, if one already exists, display the message:


If select.Next() Then
Refuse = True;
Message = New MessageToUser;
Message.DataKey = Select.Link;
Message.Field = "id";
Message.Text = "A section with this Id already exists";
Message.Message();
endIf;

In this example, double-clicking will open a directory element with the same Id, and the Id field will be active and contain a hint:

It seems convenient, we can both change the Id of the new element and edit the old one, it’s easy to get into it by clicking on the message. But the field in the current element is not activated, which, with a large number of fields, can be more useful than opening the form of another object. After all, another object has already been recorded and is being used, and the likelihood that there is an error in it is small. Most likely we need to edit the current element.

To do this, change your code as follows:

//if there are duplicates, the sample will contain data
If select.Next() Then
Refuse = True;
Message = New MessageToUser;
Message.DataKey = Object.Link;
Message.Field = "id";
Message.Text = "A section with this Id already exists";
Message.Message();
endIf;

The only difference is that in DataKey we pass a link to the element that we have open. Unfortunately, this code does not work: (Double-clicking will open a modal window.

For this to work, there is a nuance that you need to fill out the " PathToData". I can’t explain exactly why, I just need to remember this. Open another object - data path not needed, position ourselves inside the current one - needed. Conclusion - it’s better to always fill it out, you can’t go wrong. Add the line to the code:

Message.DataPath = "object";

And everything is beautiful:

There is one more nuance that I want to talk about. If the “field” is left empty, then positioning on the control element will not occur and a tooltip will not appear next to it. If the “field” is filled in incorrectly, then positioning will occur on the form as a whole and a tooltip will appear, but at the end of the form, without reference to the real input field.

The next nuance is that the message has a method - " SetData". Based on the object, it fills in the fields DataKey And PathToData. It is much more convenient to do everything in one line. Typically, in the form of an element/document, we have an object. The only thing that needs to be written on the server is this:

Message.SetData(FormAttributesValue("Object"));

But in the predefined procedure of the form Before Recording On Server in fact there is already a parameter CurrentObject. But on the client we won’t receive the object at all. Even in the object module (not in the form) you need to write this:

Message.SetData(ThisObject);

In conclusion, I want to say some nasty things about managed forms. This applies to both TAXI and regular UVs. The fact is that interface lists are transferred very poorly to UV. A table containing 1000 rows is drawn very slowly, and in a web browser it can take several minutes to open. This also applies to the message list. For an experiment, display 1000 messages and try switching between windows. The system will die immediately. Moreover, it is clearly visible how the system thinks about the output of messages. Going to a window with a bunch of messages looks like this:

The contents of the window are displayed
-which flickers sharply and the message bar appears
-everything hangs and you watch how the scroll in the message window creeps down

Those. As before, it is impossible to display a long-term processing log in the message panel, which contains several thousand records. I would recommend limiting yourself to 10 messages. Logs must be output to a multi-line line; it is displayed almost instantly, regardless of the number of lines. Of course, if you are checking the completeness of the details of the tabular part, there are 1000 rows in it and there is an error in each, then yes, you will have to wait :) Although in this case you can think about your own way of displaying messages, for example in an HTML document field.

But some aspects of working with the “Message to User” object remained not covered in it. For example, what to write in the "Field" field if the name

props differs from the field name on the form. What to write in the "Path to Data" field. And finally, the most delicious thing is how to work with the tabular part.

All research is collected in a test database. It contains a couple of reference books and a document. The document form has several buttons, when clicked, various types of messages are displayed. Well, now about each moment in order, let's go!!!

Everything I write below has been tested on 1C:Enterprise 8.3 (8.3.7.1860). Not the latest to date, but I’m writing it as it is.

1. Just a message.

Let's start with something simple: just display a message in the form, without reference to fields, data, etc.

I talked about this earlier, but for the integrity of the article I will write it again. Especially with some additions.

Message1 = new MessageToUser;
Message1.Text = "1. just a message without any bindings";
Message1.Message();

This code can be executed on both the client and the server. This is almost a complete analogue of the line:

Report("1. just a message without any bindings");

Why is it more correct to communicate not with a procedure, but with an object. The fact is that messages issued in a background task (for example, when executing a routine procedure according to a schedule) are not displayed anywhere. But what is communicated by the object can be

receive on the server in a client session using the "GetMessagesToUser(...)" method while the background job is alive.

Here I lied to you a little, I never checked it. It is quite possible that messages issued by the “Report(...)” procedure can also be obtained from a background job, but maybe not. The documentation doesn't say about this, which means we

we won't do it.

So, the conclusion: now always make messages an object, this is kind of a good form of the new platform, and forget the procedure. If you don’t like writing a message in three lines, then write your procedure in a general module and be happy. It will even

very good tone, because You will receive a number of advantages:

1. Expanded functionality of the new object (more details below)

2. The ability to display messages in your own way. For example, in a text field or file, and not in a message box.

3. Possibility of logging. For example, you can save all messages in the database or to a file, or duplicate them in the log, to do this, just tinker with your common module procedure. And then the debate is that the program is nothing to the user

did not inform will stop forever.

2. A message associated with an object attribute.

As I wrote in the previous article, to bind you need to fill in the “Field” and “PathKData” fields. But I did not cover the topic in detail in the article.

So example 2 in the document there is a header attribute “Client”, you need to position yourself on it and report something in the client procedure. Here's the code that does this:

Message2 = new MessageToUser;
Message2.Text = "2. Message associated with the Client header attribute";
Message2.Field = "Client";
Message2.DataPath = "object";
Message2.Message();

And here are the nuances:

1. A field is not a field, because in my example the control is called "FieldClient" and the object prop is "Client". The line Message2.Field = "FieldClient" does not work.

2. The Path to Data is not “Object.Client”, but simply “Object”, because We need to show the message not in the form of the counterparty, but in the form of the current document. "Object.Client" - does not work.

3. This is an example of working on a client. In server procedures, it’s a little different. This is IMPORTANT, do not confuse the binding of messages on the server and on the client.

I will give one more example so that you can feel the difference between a client and a server. The fact is that we have at our disposal the object method “SetData(...)”. The syntax helper says "The object with which there should be

message is associated." This is important. For example, let's write the following code:

Message3 = new MessageToUser;
Message3.SetData(Object);
Message3.Text = "3. Message linked to the header attribute Number, but it will not be linked because the Object is not an object";
Message3.Field = "Number";
Message3.Message();

This code won't work because... on the client, the “Object” form attribute is not an object at all, but some kind of nasty thing, this is what the debugger tells us about the object variable:

More precisely, the user will of course see the message, but double clapping on it will not lead to anything.

Now let's try the same thing, but on the server. Let's create a server procedure "Report4OnServer()" and call it from the client

&On server
Procedure Report4OnServer()
Message4 = new MessageToUser;
Message4.SetData(FormAttributesValue("Object"));
Message4.Text = "4. Message associated with the Organization header attribute";
Message4.Field = "Organization";
Message4.Message();
End of Procedure

Everything will be fine here, the only remark on the code is that the “object” variable must be converted from “FormDataStructure” into a real object by calling the “FormAttributesValue(...)” procedure.

Conclusion: the "SetData(...)" method can only be used on the server, because only on the server is it possible to receive an object.

3. Messages linked to the attribute of the tabular part of the object

I omitted this topic in the previous article. Knowing the nuances described above, there should be no problems here. Here is the working client code:

Message5 = new MessageToUser;
Message5.Text = "5. Line 1 field quantity";
Message5.Field = "Products.Quantity";
Message5.DataPath = "object";
Message5.Message();

Although the nuances are almost the same, repetition is a mother lesson:

1. The field is not the name of the control; my control is named “ProductsQuantity”, not just “Quantity”. "Products" is the name of the tabular part, not the control element associated with the tabular part.

2. The path to the data is an object, just an object.

3. Line number in square brackets - numbering from scratch and this is the line number, not the line identifier in the form data collection. When lines are shifted or deleted, the identifier assigned when opening the form is saved, and the line numbers are recalculated.

That's it for this time. I’ll immediately mention undisclosed topics that I’ll write about later:

1. How to bind messages not to the current object, but to any object, so that when double-clicked, another form opens

2. How to bind messages to a form where there are no objects

3. How to receive messages about the execution status of a long-background job

4. What is a “Data Key” and when should you use it?

Below is a database with an example, in it go to the document and press three buttons in turn. Code in the document form module.

During the lesson we: created a base, created processing, created a form.

Now we will tell you 5 methods of messages from 1C “Hello, world!”

Not everyone knows about at least two methods :)

How and where to write program text?

Switch to the tab of the window with the “Module” form. You will make sure that you already have some text there (“Procedure…”).

If there is no text, then:

  • In the thick client you added the form to processing incorrectly, repeat from the beginning
  • You forgot to add a button in the thin client, repeat from the beginning.

Inside the text there is a line:

// Insert the contents of the handler

Your task is to erase this line and enter the program text in its place. After that, save the processing and open it in enterprise mode.

When you click Execute, the actions you entered will now be performed.

Now let's move on to the methods themselves!

Message in 1C, method 1 - the easiest

So you should instead of the text “// Insert the contents of the handler.” write the program text.

Report("Hello world!");

Actually that's all :)

The message in Enterprise mode in the thick client will be at the bottom of the 1C window, in the thin client - on the right in the processing window.

This is the simplest method, very widely used by programmers.

Message in 1C, method 2 - also simple

Alert("Hello world!");

Actually that's all :)

The message in Enterprise mode in both client options will be in a pop-up window.

Message in 1C, method 3 - appeared only in 1C version 8.2

ShowUserAlert("Hello, world!","Hello indeed!");

This method appeared only in 1C version 8.2. This is a pop-up window in the lower right corner of the screen that goes away over time.

Message in 1C, method 4 - programmer

Throw Exception "Hello, world!";

There can be an error when executing any program. Sometimes this error can be calculated in advance (for example, you need to calculate a = b/c and at the time of program execution it becomes known that c is equal to 0).

In this case, there is a way to report the error using this method.

Message in 1C, method 5 - technologically advanced, only for standard configuration

General Purpose.ReportError("Hello, world!");

A 1C programmer must know not only the programming methods that are available in the 1C platform, but also those that are available in standard configurations.

Beginners, when trying to add any standard configuration, begin to reinvent the wheel.

Here's a perfect example. This feature is present in many standard configurations (thick client only!). It would seem that the result is equal to the action of method 1.
However, no - in some configurations (for example soft starter), error messages are duplicated in the log. Also, with additional settings, the message looks completely different.

So, now you can feel like a real programmer!

This is exactly what 1C programming is. Of course, real programming is much more complex and requires a lot of knowledge, but you now have a general idea.

Good luck!

P.S. The pdf version of the lesson contains screenshots to make it easier to make your own experience.

P.P.S. The lesson includes 5 videos with examples of creating a base for programming, creating processing, programming in a thick and thin client.