Windows.  Viruses.  Laptops.  Internet.  Office.  Utilities.  Drivers

This code allows you to open a list of documents with a specified selection; you can also open a list of directory elements with the desired selection

Code 1C v 8.2 UP Form = OpenForm("Document. Invoice.Form.ListForm"); //Open the form
SelectionOwner =Form.List.Selection.Elements.Add(Type("DataCompositionSelectionElement")); //Add selection
SelectionOwner.ComparisonView = DataCompositionComparisonView.Equals; //How will we compare
SelectOwner.Use = True; // Set the checkbox for using NewDataCompositionField("Nomenclature")
SelectionOwner.LeftValue = NewDataCompositionField("Account"); //What details will we use to make the selection?
SelectionOwner.RightValue = Object.Account; // And the very meaning of selection

In order to open a list form with a predefined selection use the following methods:

First way is that when you open a form, you can set the Selection form parameter and open the list form with this parameter.

The Selection parameter represents the structure. The names of the elements correspond to the names of the fields by which the selection is made, and the values ​​contain the selection values. This is a dynamic list managed form extension option. That is, it exists for forms whose main attribute is an attribute of the DynamicList type, for example, for list forms and selection forms.

For example, in the following example, a list of invoices is opened with selection by the Number field, equal to 333.

Code 1C v 8.2 UE Selection Value = New Structure("Number", "333");
SelectionParameters = New Structure("Selection", SelectionValue);
OpenForm("Document. Receipt Invoice. List Form", Selection Options);

Second way

You can open a list form without parameters:

Code 1C v 8.2 UP OpenForm("Document. Receipt Invoice. List Form");

And then, in the event handler of the form for the list of invoices When CreatedOnServer, write code that creates a selection in the dynamic list, which is the main attribute of the form:

Code 1C v 8.2 UP &OnServer
Procedure When CreatedOnServer(Failure, StandardProcessing)
Selection Element = List.Selection.Elements.Add(Type("DataComposition Selection Element"));
SelectionElement.LeftValue = NewDataCompositionField("Number");
SelectionElement.ComparisonView = DataCompositionComparisonView.More;
SelectionElement.Use = True;
SelectionElement.DisplayMode = ElementDisplayModeDataCompositionSettings.Inaccessible;
SelectionElement.RightValue = "000000001";
EndProcedure

The advantages of this method are that the Comparison Type for the selection can be set not only to Equal, as in the first case, but also to More, Less, etc.

But this method also has a very significant drawback: with this selection, the form will always open. Wherever she was called from. Therefore, this form should not be designated as the main one. And if, nevertheless, it is the main one, then before installing the selection it is necessary to provide some kind of analysis of where this form opens from. For example, analyzing form parameters.

Third way

Finally, the selection condition can be placed in a custom query that selects data for a dynamic list.

For example, we need to open a list of invoices that contain the item highlighted in the item list.

To do this, in the form of a list of items, create a command and the corresponding button Receipt invoices.

Let's fill out the execution handler for this command as follows:

Code 1C v 8.2 UP &OnClient
Procedure ReceiptsInvoices (Command)
SelectionParameters = New Structure("FilterByProduct", Elements.List.CurrentRow);
OpenForm("Document. Receipt Invoice. List Form", Selection Options);
EndProcedure

In this handler, we open the form for the list of invoices, passing a link to the current item in the item list to the FilterByProduct form parameter.

Then we will create a form for the list of documents: Receipt Invoice and create a FilterBy Product form parameter, which we will use to open a form with the required selection.

Now let's open the properties palette of the main attribute of the List form. Set the Custom Query flag and in the List Settings line click Open.

In the Request field, enter the following request text:

Code 1C v 8.2 UP SELECT
Document Receipt Invoice. Number,
Document Receipt Invoice.Date
FROM
Document.ReceiptInvoice AS DocumentReceiptInvoice
WHERE
Document Receipt Invoice.Products.Product = &Product

In the request, we use the Item parameter, which will receive a link to the current line in the item list, contained in the FilterBy Item invoice list form parameter.

To do this, in the list form event handler When CreatedOnServer, we will write code to set the value of the Product request parameter:

Code 1C v 8.2 UP &OnClient
Opening Procedure (Failure)
List.Parameters.SetParameterValue("Product", Parameters.FilterByProduct);
EndProcedure

Here List.Parameters is a list of dynamic list request parameters for the List attribute. The value of the Product parameter is set equal to the value of the FilterByProduct form parameter.

As a result, by clicking the Receipt invoices button in the item list form, we will receive a list of only those invoices that contain the item currently selected in the item list.

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.

There are several ways to open a list form with some pre-set selection. Let's look at them:

  1. First way is that when opening a form you can set a form parameter Selection, and open the list form with this parameter. Parameter Selection represents a structure. The names of the elements correspond to the names of the fields by which the selection is made, and the values ​​contain the values
    selection This is a dynamic list managed form extension option. That is, it exists for forms whose main attribute is the type attribute DynamicList, such as list forms and selection forms.

When opening the form, selection will be made based on the specified field. For example, in the following example, a list of invoices is opened with selection by the Counterparty field equal to “OJSC Horns and Hooves”.

Selection Value = New Structure (“Counterparty” , "JSC Horns and Hooves");
Selection Options= New Structure("Selection", SelectionValue);
OpenForm (“Document. Receipt Invoice. List Form”, Selection Options);

2. You can open a list form without parameters:

OpenForm (“Document. Receipt Invoice. List Form”);

And then, in the event handler of the invoice list form When CreatedOnServer write code that creates a selection in a dynamic list, which is the main attribute of the form:

&On server
Procedure When CreatedOnServer(Refusal , StandardProcessing)
Selection Element = List . Selection. Elements. Add (Type
(“DataCompositionSelectionElement”));
Selection Element .LeftValue = New Data Layout Field("DocumentAmount");
Selection Element. Comparison View = Comparison ViewData Layout. More ;
Selection Element. usage = true;
Selection Element. RightValue = 150000;
EndProcedure

The advantages of this method are that ViewComparison the selection can be set not only Equals, as in the first case, and More, Less and so on.

But this method also has a very significant drawback: with this selection, the form will always open. Wherever she was called from. Therefore, this form should not be designated as the main one. And if, nevertheless, it is the main one, then before installing the selection, it is necessary to provide some kind of analysis of where this form opens from. For example, analyzing form parameters.

3. And finally, the selection condition can be placed in a custom request, which selects data for a dynamic list. For example, we need to open a list of invoices that contain the item highlighted in the item list.

To do this, in the form of a list of items, create a command and a corresponding button ConsumablesInvoices

Let's fill out the execution handler for this command as follows:

&OnClient
Procedure ConsumablesInvoices(Team )
ListForm = GetForm("Document.Invoice.ListForm");
ListForm. FilterByProduct = Items . List . CurrentRow ;
ListForm. Open();
EndProcedure

In this handler we receive the form of the list of invoices and pass it to the form parameter FilterBy Product link to the current item in the item list and open the form with this parameter.
Then we will create a document list form Sales Invoice and create the form attributes FilterBy Product, which we will use as a form parameter when opening it. Now let’s open the properties palette of the main form attributes List. Let's set the flag CustomRequest and in
line List setup let's press Open.

In field Request Let's enter the following request text:

CHOOSE

Document Receipt Invoice. Number,
Document Receipt Invoice.Date
FROM
Document.ReceiptInvoice AS DocumentReceiptInvoice
WHERE
Document Receipt Invoice.Products.Product = &Product

In the request we use the parameter Product, to which the link to the current line in the item list, contained in the attribute of the invoice list form, will be sent FilterBy Product. To do this, in the list form event handler WhenOpening Let's write the code to set the value of the Product request parameter:

&OnClient
Opening Procedure (Failure)
List . Options . SetParameterValue("Product", FilterByProduct);
EndProcedure

Here List.Options— this is a list of dynamic list request parameters for the List attribute. Parameter value Product is set equal to the value of the form parameter FilterBy Product. As a result, at the click of a button Invoices in the form of an item list, we will receive a list of only those invoices that contain the item currently selected in the item list.

— this is a list of dynamic list request parameters for the List attribute.

Code 1C v 8.x DirectoryList.Selection.Reset();
DirectoryList.Selection.status.ComparisonType=ComparisonType.Contains;
DirectoryList.Selection.Status.Value="Accepted";
DirectoryList.Selection.Status.Set();

For 1C 8.2:
There are several ways to open a list form with some pre-set selection. Let's look at them in order:

1. The first method is that when opening the form, you can set the Selection form parameter and open the list form with this parameter. The Selection parameter represents the structure. The names of the elements correspond to the names of the fields by which the selection is made, and the values ​​contain the selection values. This is a dynamic list managed form extension option. That is, it exists for forms whose main attribute is a Dynamic List type attribute, for example, list forms and selection forms.

When opening the form, selection will be made based on the specified field.
Code 1C v 8.2 UP // For example, in the following example, a list of invoices is opened with selection by the Number field equal to 333.
Selection Value = New Structure("Number", "333");
SelectionParameters = New Structure("Selection", SelectionValue);

OpenForm("Document. Receipt Invoice. List Form", Selection Options);

// For example, the following example opens a list of invoices
// with selection by the Contractor field equal to “OJSC Horns and Hooves”.
Selection Value = New Structure("Counterparty", "OJSC Horns and Hooves");
SelectionParameters = New Structure("Selection", SelectionValue);
OpenForm("Document. Receipt Invoice. List Form", Selection Options);

2. You can open a list form without parameters:
Code 1C v 8.2 UP OpenForm("Document. Receipt Invoice. List Form");

And then, in the event handler of the form for the list of invoices When CreatedOnServer, write code that creates a selection in the dynamic list, which is the main attribute of the form:
Code 1C v 8.2 UP &OnServer

Selection Element = List.Selection.Elements.Add(Type("DataComposition Selection Element"));
SelectionElement.LeftValue = NewDataCompositionField("Number");


SelectionElement.DisplayMode = ElementDisplayModeDataCompositionSettings.Inaccessible;
SelectionElement.RightValue = "000000001";
EndProcedure

&On server
Procedure When CreatedOnServer(Failure, StandardProcessing)
Selection Element = List.Selection.Elements.Add(Type
(“DataCompositionSelectionElement”));
SelectionElement.LeftValue = NewDataCompositionField("DocumentAmount");
SelectionElement.ComparisonView = DataCompositionComparisonView.More;
SelectionElement.Use = True;
SelectionElement.RightValue = 150000;
EndProcedure

The advantages of this method are that Comparison View for selection, you can set not only Equal, as in the first case, but also More, Less, etc.

But this method also has a very significant drawback: with this selection, the form will always open. Wherever she was called from. Therefore, this form should not be designated as the main one. And if, nevertheless, it is the main one, then before installing the selection, it is necessary to provide some kind of analysis of where this form opens from. For example, analyzing form parameters.

3. Finally, the selection condition can be placed in a custom query that selects data for a dynamic list. For example, we need to open a list of invoices that contain the item highlighted in the item list.

To do this, in the form of a list of items, create a command and the corresponding button Receipt invoices.

Let's fill out the execution handler for this command as follows:
Code 1C v 8.2 UP &OnClient
Procedure ReceiptsInvoices (Command)

ListForm = GetForm("Document.Invoice.ListForm");
ListForm.FilterByProduct = Items.List.CurrentRow;
ListForm.Open();

EndProcedure

In this handler, we receive the form for the list of invoices and pass the link to the current item in the item list to the FilterByProduct form parameter and open the form with this parameter.

Then we will create a form for the list of documents: Receipt Invoice and create a form attribute FilterBy Product, which we will use as a parameter of the form when opening it. Now let's open the properties palette of the main attribute of the List form. Set the ArbitraryRequest flag and in the List settings line click Open.

In the Request field, enter the following request text:
Code 1C v 8.2 UP SELECT
Document Receipt Invoice. Number,
Document Receipt Invoice.Date
FROM
Document.ReceiptInvoice AS DocumentReceiptInvoice
WHERE
Document Receipt Invoice.Products.Product = &Product

In the request, we use the Item parameter, which will receive a link to the current line in the item list, contained in the FilterBy Item invoice list form parameter. To do this, in the OnOpen list form event handler, we will write code to set the value of the Product request parameter:
Code 1C v 8.2 UP
&OnClient
Opening Procedure (Failure)

List.Parameters.SetParameterValue("Product", FilterByProduct);

EndProcedure

Here List.Options is a list of dynamic list request parameters for the List attribute. The value of the Product parameter is set equal to the value of the FilterByProduct form parameter.

As a result, by clicking the Receipt invoices button in the item list form, we will receive a list of only those invoices that contain the item currently selected in the item list.

If you notice an error, select a piece of text and press Ctrl+Enter
SHARE: