Let us implement picking a single item.
- In Designer, open the GoodsReceipt document form.
- On the Commands tab, create the Pick command.
- In the command property palette, in the Action field, click the Open button and specify that the command is executed on the client.
- Click the Form tab and drag the command to the form controls pane, to the command bar of the Materials table (fig. 26.1).
Fig. 26.1. Creating the Pick button - Click the Module tab and add the script shown in listing 26.1 to the Pick command handler.
Listing 26.1. Pick command handler
&AtClient Procedure Pick(Command) OpenForm("Catalog.MaterialsAndServices.ChoiceForm", , Items.Materials); EndProcedure
The procedure opens the MaterialsAndServices catalog selection form, which is subordinate to the Materials table of the GoodsReceipt document (Items.Materials).
Once a user selects a value from the catalog selection form, the value is passed to the ChoiceProcessing event handler of the Materials table because the table is the owner of the selection form. - Open the property palette of the Materials table and create a ChoiceProcessing event handler (fig. 26.2) that is executed on the client (listing 26.2).
Fig. 26.2. Creating the ChoiceProcessing event handler for the Materials table
Listing 26.2. ChoiceProcessing event handler for the Materials table
&AtClient Procedure MaterialsChoiceProcessing(Item, SelectedValue, StandardProcessing) Items.Materials.AddRow(); Items.Materials.CurrentData.Material = SelectedValue; EndProcedure
The procedure adds a row to the Materials table and assigns the value selected in the catalog selection form to the Material column of that row. This value is passed to the handler as the SelectedValue parameter.