📜 ⬆️ ⬇️

Notification by mail from 1C

What for?

I decided to write this article, because I myself did not find information on this issue in my time.
I had to look for a solution myself. Just in case, publish it on Habré - suddenly someone will come in handy.

I work as a 1C programmer in large-scale production. Due to its peculiarities, employers often set tasks for the organization of business processes with various coordination systems.
And often one of the key requirements in such technical tasks is the possibility of notifying a person about the creation of some kind of action in the system or simply that some resolution is required of him. There are quite a few such cases: reconciling a new order, a new nomenclature, sometimes, the security service wants to know which users and with what rights have been added to the system, or some of its own ITIL system is organized, and the boss wants to notify his workers about the new tasks. And so on.

Most often it is necessary to notify superiors. But they often do not sit in one place, they strongly do not want to always keep open 1C and ask to notify them in other ways.

And one of the easiest solutions for such tasks, as I see it, is to create email notifications, that is, sending alerts to the addressee’s mailbox, because everyone uses mail services, plus almost always the user has collector programs that notify him of new letter. Moreover, sending a message to the mail is quite an easy task for 1C.
')
 =  ;  =  ; .SMTP = "dmz-server17"; //   SMTP .SMTP = 25; //    =  ();  .();  ("    ,    !", .); ; ; . = «»; ..(«»); ..(«»);//   .        . = «»; .(); 


This code can be placed both before writing the document or in the “handler” of the button.

Managed Forms and Web Client

All this seems to work well, and the “letters of happiness” come to the right people, but even here there is one snag. If these are not only notification letters, but some kind of reciprocal action is implied (or more details need to be reflected), the user should still go to the 1C program, open the list of documents of the desired type and find the necessary document. Of course, we will facilitate his work and in the letter we can specify the date and number of the letter, but still it comes down to the launch by the 1C user, and we are trying to avoid it!

This is where 1C 8.2 comes to the rescue with their managed forms and the web client. Without going into details, the essence of the process is as follows: the web server rises, your configuration is published there - and now you can work in 1C through almost any browser.
And if earlier the document was identified by two parameters: “Date” and “Number” - now the so-called “navigation link” has become available to us. Its charm is that after the user navigates through it, 1C immediately opens the document to which it refers, and frees the user from his search.

True, there is one BUT here: the navigation links work ONLY with managed forms. Yes, rewriting the basic functionality of typical configurations (where 1C specialists themselves did not do this) into controlled forms is long enough, however, if we are talking about some kind of “intra-organizational” coordination and notification modules, then this will not be difficult.

Hence the following solution: it is necessary to include this link in the notification letter, so that the user can immediately click on the link, go to the desired document (on the web client) and do the necessary things. This is solved only in a couple of lines:

 …  = "http://__/#"+ (.);  = (,"""","%22"); ..("<a href =" + """" +  + """" + ">  № "+(.) + "  " + (.) + "</a>" ,.HTML); … 


In the code, the parameter "Source" is passed to the procedure, which is the "Object" (link), which, in turn, caused this procedure.

When working with navigation links, you should consider one nuance. This link is created and assigned to the object only at the moment of its recording in the database. That is, if this is a new document, then it will NOT have this navigation link before recording. This nuance should always be remembered, and there are two solutions to this problem: either to establish a link to the document itself, or, what I like more, to send letters in the “PostWrite On Server” handler.

1C 8.3.2

More recently, 1C announced the release of version 8.3.2 of the platform, where one of the “features” is the ability to “compile” configurations into applications for installation under Android and iOS. It seems to me that this opportunity is quite interesting, although it is still “raw”. But if everything goes well, in the near future it will be possible to send such notifications not only to the post office, but directly to the phone to the superiors - so that they can coordinate various processes, wherever they are, without distracting from their important affairs.

Source: https://habr.com/ru/post/153579/


All Articles