I want to generate forms just once. I gave same document number to generated form when it is filling. So i can find if it has generated before during the filling operation. But i can not open generated form with openvalue() function, because filling procedure working at server.
How can i open generated during the filling procedure?
Could you please clarify what behavior you would like to implement in the sample?
1. Select Document1 with Number=2.
2. Click Generate > Document2.
3. Post Document2 with Number=2.
Expected result: 1C:Drive successfully posts Document2 with Number=2.
4. Select Document1 with Number=2.
5. Click Generate > Document2.
Expected result: 1C:Drive finds out that Document2 with Number=2 already exists, notifies you about that, and does not populate the form for Document2.
An example of checking if the document the user tries to create already exists is available in the attached infobase.
Please notice that the correct approach to implement the scenario you want is to use the "generate something based on something by using a hyperlink within a form" functionality. An example of this functionality is available in 1C:Drive demo: take a look at sales invoice and tax invoice documents there.
In your scenario, we recommend you to add an attribute to Document2, store a reference to Document1 in the attribute, and search for values of this attribute. This is a more reliable search strategy in comparison with searching for a document by its number.
When searching for a document by its number, the user may encounter situations when these numbers differ in Document1 and Document2 (for instance, Document1 was deleted, but Document2 exists). As a result, in such situations the search for documents will work incorrectly.
Searching for documents by reference does not have this shortcoming.