1c in the selection parameters, set the group name. Set selection parameters and selection parameter associations for metadata objects. DescriptionofTypesInventory = NewDescriptionofTypes(Array)

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 in a manageable 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.

/
Developers /
Coding Conventions

Setting Selection Options and Selection Option Associations for Metadata Objects

1. As a rule, business logic restrictions such as selection restrictions must be the same for all forms in which a particular object is edited. Therefore, it is recommended to set selection parameters and connections between selection parameters in the properties of metadata objects - in the details of directories, documents, etc.

2. However, there may be cases where the selection restrictions may depend on the specific operating scenario. In such cases, the selection parameters can be specified locally, in a specific form.

For example, the configuration contains

  • directory Employees, which contains details Organization And Employee Type(enumeration with values Basic/Part-timer);
  • document Reception Order, which contains props Organization And Employee; while for the props Employee document Reception Order selection parameter connection is specified Selection.Organization with props Organization.

It is required to implement the ability to select only key employees depending on the value of the functional option SelectOnlyFromEmployeesBasics. For this it is necessary

  • in the form of a document Reception Order implement additional form attributes Types of Employees,
  • then for the form field Employee a selection parameter link can be established Selection.Type of Employee with form details Types of Employees,
  • in this case the form details Types of Employees filled in based on the analysis of the functional option.

(At the same time, set for the props Employee document Reception Order link for selection parameter Selection.Type of Employee there is no possibility, because props Employee Type in the document Reception Order does not exist.)

Then setting the connection for the parameter Selection.Organization in prop properties Employee document Reception Order and connections for the parameter Selection.Type of Employee in the document form field Reception Order will lead to the fact that in the mode 1C:Enterprises Both selection parameter links will work. Thus, when selecting an employee in the hiring order form, the selection in the list of employees will be determined both by the organization filled out in the document and by the type of employee, which will be determined based on the functional option.

Good afternoon.

Today we'll talk about how to programmatically open selection forms in the new managed interface.

Previously in " regular application"We wrote like this:

form = Directory.nomenclature.GetSelectionForm();

resultSelection = form.openModalNO();

Between these operators we could change the properties of the form, for example, set the selection. We could specify a specific form by name. Could change it appearance, accessing the form element properties by their name through a dot (form.Button1.Visibility = False;)

Now we have a managed interface and everything is different here. The problem is in dividing the code into server and client parts. We can access objects and their metadata only on the server, and we must open forms on the client.

So let's get started.

1. The simplest case is when we do not need to manage the selection (set up selections, pass parameters to the opened selection form).

Since forms can only be opened on the client, this will be a client-side piece of code. We will use the function EnterValue(<Значение>, <Подсказка>, <Тип>) . Actually, everything is clear from her description. It returns the flag of whether the user made a selection; in the first parameter we pass the container into which the selection value will be returned, in the second text that will be displayed in the title of the selection window, in the third array of types.

Here is an example of use:

Variable SelectTMC;

ArrayTypes = New Array;

DescriptionofTypesTMC = NewDescriptionofTypes(Array);

If EnterValue(Select Inventory, "Select Item", Description of Inventory Types) Then

//Processing the selected value

endIf;

I’ll add that if we assign any value to our container variable before selecting it, it will be the default value. In this case, you don’t have to form an array of types; the type will be taken from the value in the container.

2. Sometimes, before selecting a value, we need to set some selections and selection parameters. For example, we need to select a counterparty agreement. The first method will open all the documents for us, but we need to select by owner.

There are two methods for opening forms: OpenForm And OpenFormModal. In the first method, we will open the form and the piece of code from which we opened the form will continue to execute without receiving the result of the selection. The selection result, depending on the call method, will be placed either in the input field or received in the predefined procedure "Selection Processing".

In our case, we need to get the selected value into a certain variable and continue processing taking into account the selected value, without transferring control to other procedures. Therefore it will suit us OpenFormModal.

I’ll make a reservation right away that this is a bad way for a web interface, because... Modal windows open in a new browser window that is usually blocked. But if you explain to the user in advance what’s what, then I think he will cope with this problem))

So, let's look at the description of the procedure, it has 4 parameters. In the first, we indicate a line with the full path to the form "Directory. Contracts of Contractors. Selection Form". In the second, we indicate the selection parameters, more about them below. In the third - the owner, this is a form or selection field that will receive the result of the selection, we do not fill it out. The fourth parameter is also not used in our case.

So, for a simple selection, the following line will do:

&OnClient

Procedure Command1(Command)

res = OpenFormModal("Directory. Contracts of Contractors. SelectionForm");

End of Procedure

But this is a complete analogue of method No. 1, and we will see a form for selecting all contracts, without selecting by owner. Those. This can only be done if we want to specify the name of the selection form.

To set the selection, the second parameter will help us.

The second parameter is of type "Structure". As structure elements, you can specify form parameters added on the “parameters” tab of the selection form. Their processing should be described in the procedure When CreatedOnServer in the selection form module. This is not good for us, because... I need to modify the configuration. You can also pass a selection structure with the “selection” key in the parameter structure. Then all fields from the selection structure will be used in selecting the list of elements and will not be available to the user either for viewing or changing.

In my example, I drew a selection field in the processing that refers to the processing form attribute "counterparty" with data type " DirectoryLink.Counterparties". and wrote the following piece of code:

&OnClient

Procedure Command1(Command)

Selections = New Structure("Owner", Counterparty);

SelectionParameters = New Structure("Selection", Selection);

res = OpenFormModal("Directory. Contracts of Contractors. Selection Form", Selection Parameters);

End of Procedure

This is usually enough to solve most problems and does not require any configuration intervention. However, in the selection form in the “When CreatedOnServer” procedure, your selection may be lost. Therefore, before using this method, review this procedure in the selection form you open. Crooked developers there can easily set their selection “by default”, forgetting to check that the selection is passed in the opening parameters.

That's all for today, thank you for your attention.




Top