1c how to open a managed form from a regular one. How to open a form of an existing object? How to open an object form in a managed application if there is a link to it

Home For beginner developers Learning to program

How to open a form of an existing object?

When opening a form of an existing object, in addition to the name of the form, you must also indicate the object whose form should be opened. To do this, use the Key form parameter and a link to the object of interest to us.

For example, if from the list of organizations form you need to open the form of the organization on which the cursor is located, you can do this in the following way:

We pass form parameters in the form of a structure, where the name of the structure element corresponds to the name of the form parameter, and the value is the value to which we want to set the form parameter.

If you want to open not the main, but an arbitrary form of an object created in the configurator, instead of the standard name of the main form (ObjectForm), indicate the word Form followed by a dot - the name of the form created in the configurator.

For example:

ReferenceToDirectoryElement = Elements.List.CurrentRow; FormParameters = New Structure("Key", ReferenceToDirectoryElement); OpenForm("Directory.Organizations.Form.UniversalObjectForm",FormParameters);

It should be noted that in the case when, in addition to a link to an object, no parameters need to be passed to the form being opened and it is the main form of the existing object that is needed, you can use a simpler method - open the form using the procedure OpenValue():

OpenValue(Items.List.CurrentRow);

This method is less versatile, but in some cases it saves time and effort. For example, in the case considered, one such line can replace the entire three-line procedure we wrote earlier.

However, care must be taken when using this procedure. In some cases, it may cause additional calls to the server, for example, when you need to open a hierarchical directory item form. When using this procedure, the platform will make an additional call to the server to determine whether an element is a group or not, since different forms must be opened for the element and for the group.

At the same time, this information can be known in advance to the developer within his algorithm, and, using the OpenForm() function, the developer can open the desired form without additional calls to the server, immediately specifying the standard name of the main form.

In order to open the selection form with selection in 1s 8.2(regular forms), we need to perform some actions. We'll get it first. After that, we’ll set the selection and open it programmatically, here’s a code example:

Selection on the form in the 1C 8.2 input field with several values

In the example above we looked at how to set selection on the selection form by specific value. Now let's look at a situation where you need to substitute several values, this could be, for example, an array or unloaded from a query result. This is a selection in the 1c input field with multiple meanings.

First, we get the selection form, pass “Element” (owner) in the parameters, set the selection mode flag. Then we create a list of values ​​and an array, we note that as a selection when setting the type of comparison in the list, an object can only be present with the type ListValues. We add elements to the array, then load this array into the List of Values, which we subsequently set in the selection. Also, don’t forget to enable the flag for using this selection and set the Comparison Type.

Setting selection in the input field on the form in 1C 8.3, Start of Selection event

Now let's consider selection in the input field on a managed form in 1C 8.3. Let’s find on the form the element we are interested in, in which we will set the selection, in our case this is the “Organization” field. We find the “Start of Selection” event, click on the magnifying glass and find ourselves in the procedure. We see the Selection Data parameter; this parameter is of the ValueList type. In order to limit the selection to the necessary elements, we need to fill in the List of Values. We can select elements only on the server, so we create a procedure with the &OnServer compilation directive. In this procedure, fill in the Selection Data.

S-P tells us the following:

Global context.GetForm
Global context
GetForm
Syntax:

GetForm(<ИмяФормы>, <Параметры>, <Владелец>, <Уникальность>, <Окно>, <НавигационнаяСсылка>)
Options:

<ИмяФормы>(required)

Type: .
Form name. Formed as a full path to the Form metadata object (for example, "Directory. Counterparties.Form.ObjectForm", "GeneralForm.FileSavingForm") or as a full path to an application object, supplemented by the default form name (for example, "Directory.Products.SelectionForm" ).
Default form names:

  • ObjectForm - default object form;
  • GroupForm (FolderForm) - default group form;
  • RecordForm - default register entry form;
  • ListForm - default list form;
  • ChoiceForm - default choice form;
  • GroupChoiceForm - default group selection form;
  • ConstantsForm - the default constants form for normal mode, set as the constants form for configuration;
  • Form - the default form of the constant, report and processing;
  • CommonForm - general form;
  • SettingsForm - default report settings form;
  • LoadForm - form for loading settings;
  • SaveForm - form for saving settings;
  • VariantForm - form for editing a report variant;
  • SearchForm - a form for full-text search in data.
For example, to obtain the general form "GeneralSettings" you should write the following code in the module:
Form = GetForm("GeneralForm.GeneralSettings");

For external reports and processing, the form name is specified as follows:

  • ExternalReport.<имя отчета>.Form.<имя формы>;
  • ExternalReport.<имя отчета>.<имя стандартной формы>;
  • ExternalProcessing.<имя обработки>.Form.<имя формы>;
  • ExternalProcessing.<имя обработки>.<имя стандартной формы>.
In this case, the external report or processing must be previously registered in the system.
<Параметры>(optional)

Type: .
Form parameters. The structure key is the name of the parameter, and the value is the value of the form parameter. The element name must match the structure parameter name.
P = New Structure("Key", Supplier);
Form = GetForm("Directory. Counterparties.ObjectForm", P);
Form.Open();
<Владелец>(optional)

The owner of a form is a form or control of another form.
<Уникальность>(optional)

Type: Free.
This parameter can specify a key, the value of which will be used to search for already open forms. If a form with the same uniqueness key is found, instead of opening a new form, the found form will be activated.
- search for a form with a default uniqueness key, - do not search for a form at all, any other value sets the uniqueness key by which the search will be performed.
Default value: .
<Окно>(optional)

Type: ; .
The application window in which the form will be opened.
Applicable to managed form only. A window can only be the main application window or an auxiliary form window.
If type is specified, the form window will be created according to the selected option.
<НавигационнаяСсылка>(optional)

Type: ; .
If it contains a value other than , then that value is assigned to a property of the form resulting from calling this method, and the property of that form is set to .
Default value: .
Return value:

Type: ; ; .
- if the handler is set to reject form creation.
Description:

Gets the form or managed form. Before receiving, a search is carried out for an already open form of the same type.
The search is carried out by form type, values ​​of key form parameters, form owner, user uniqueness key.
If in the parameter<Уникальность>the value is passed, then the search for already open forms is not carried out.
Availability:

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

In the thin and web client, only the managed form is received.
Conventional forms of external processing are not supported.
If, when receiving a regular form in the parameter<ИмяФормы>A non-standard form name is specified; the passed parameters are not processed.
There may be multiple calls to the server during execution. Some of them are cached. There is always at least one request to the server and it is not cached. Caching depends on the platform version and the configuration version as a whole. If the connection speed is set to low and the current line is not specified, the selection form is cached. The cache is cleared every 20 minutes. Forms that were not used during this period of time are deleted.
See also:

Programmatically opening forms in a managed 1C application is significantly different from opening them in a regular application. Let's look at the old method first. It consists of receiving a form and then opening it in normal or modal mode (when opened in modal mode, the form blocks the program).

GetForm() . Open()

This is the slowest method of opening forms. However, it allows you to programmatically process the form before opening it. To process the code you need to change a little:

Form = GetForm( "Document. Receipt of Goods and Services. Document Form") ;
//Here we perform actions with the form
Form. Open();

It should be taken into account that when the form is received, another event procedure will be executed WhenCreatedOnServer.

Let's look at other methods that allow you to open forms in a managed 1C application faster and more conveniently. Depending on the specific situation, different methods may be used.

1. How to open an object form in a managed application if there is a link to it.

In this case, everything is extremely simple.

RefLink = Directories. Nomenclature. FindByCode("000000001" ) ;
OpenValue(RefLink) ;

2. How to open the selection form and then get the selected value.

There is a function for this EnterValue(). The function has 3 parameters:

  • The variable into which the selected value will be written;
  • A hint that will be displayed in the selection window;
  • Description of the types of selected values. There may be several types, in which case you will be prompted to select a type before selecting a specific value.

As a result of executing the function, the default selection form for an object of the specified type will open.

Variable Value;
Array = new Array;
Array. Add(Type( "DirectoryLink.Nomenclature") ) ;
Array. Add(Type( "DirectoryLink. Counterparties") ) ;

TypeDescription= new TypeDescription(Array) ;

Res = EnterValue(Value, "Hint" , TypeDescription) ;

Previous methods only allowed you to open the default forms for objects (object form or selection form). If you need to open a custom form, you can use the function OpenForm().

This function has quite a few parameters. Let's look at some of them:

  • Form name— here you can select either one of the standard object shapes, for example, Selection Form or List Form. Or a specific form created by the developers.
  • Options— allows you to transfer it to the form in the form structures some parameters before opening it, thereby determining the output data. Parameters can be any data that can be passed from the client to the server. The parameters passed when opening the form can be processed in the procedure WhenCreatingOnServer() at the form being opened.
  • Form opening mode— has 3 options: independent, block the entire interface, block the owner form.

Let's look at how the function is used OpenForm() in various situations.

3. How to open the form of an existing object

Each form has one key attribute. It is highlighted in bold in the list of form details and is usually called An object in the forms of elements of reference books and documents. Other objects may have a different name. To open a form of an existing object, you need to pass a parameter to the form being opened Key with the value as a reference to an object.

&OnClient
Procedure Command1 (Command)
Parameter= new struct;
Parameter. Insert("Key" , FindC() ) ;
OpenForm(, Parameter) ;
EndProcedure

&On server
Function FindC();
Return Directories. Counterparties. FindByRequisites ("TIN", "745107734623")
EndFunction

4. How to open a new object form

A simple function will do here OpenForm() without any parameters.

&OnClient
Procedure Command1 (Command)
OpenForm( "Directory. Counterparties. Object Form") ;
EndProcedure

5. How to open a new object form and fill it out based on something

You need to pass a parameter Base, the value of which will be a reference to the filling base object. This will start the procedure ProcessFill().

&OnClient
Procedure Command1 (Command)
Parameter= new struct;
Parameter. Insert("Base", LinkToBuyerAccount) ;
OpenForm( "Document. Sales of Goods and Services. Object Form", Parameter) ;
EndProcedure

This example will create a document Sales of goods and services and filled out on the basis of an invoice for payment to the buyer, the link to which was transmitted.

6. How to open a form and set a selection on it

Selection on 1C forms can be simple or complex. Simple selection involves expressions like Organization = Horns and Hooves LLC. Complex selection involves other types of comparison, e.g. On the list. In this article we will consider the organization of simple selection, and a separate article will be devoted to complex selection.

To organize a simple selection, you need to pass a parameter with a key to the form being opened Selection, the value will be a structure in which the key is the name of the dynamic list field, and the value is the data being sought.

For example, let's open the directory list form GTD numbers and make a selection there by owner - directory element Nomenclature.

&OnClient
Procedure Command1 (Command)
Parameter= new struct;

selection= new Structure;
Selection. Insert("Owner", LinkToNomenclature) ;

Parameter. Insert("Selection", Selection) ;

OpenForm( "Directory.GTD numbers.List form", Parameter) ;
EndProcedure

7. How to open the information register entry form

To do this, you will need the information register entry key.

Record Key— these are the values ​​of all measurements and the period (if the register is periodic). That is, a record key is the parameters by which a record can be uniquely identified.

The opening algorithm is as follows:

  1. We enter the record key data with the necessary values ​​into the structure.
  2. We place the resulting structure in an array.
  3. We create a record key from the array.
  4. We pass a parameter to the form that opens Key with the record key from step 3 as the value.

&OnClient
Procedure Command1 (Command)
Parameter= new struct;

KeyParameters= new Structure;
Key parameters. Insert("Nomenclature", LinkToNomenclature) ;
Key parameters. Insert("PriceType", LinkToPriceType) ;
Key parameters. Insert("Period", Date) ;

KeyArray = New Array;
KeyArray. Add(KeyParameters) ;

EntryKey = New( "Information RegisterRecord Key.PricesNomenclature", KeyArray) ;

Parameter. Insert("Key", RecordKey) ;

OpenForm( "Register of Information. Prices of Nomenclature. Record Form", Parameter) ;
EndProcedure