Method #1

The first method is searching for a topic in the table of contents by following down the tree while expanding the subsections, properties, links, and so on.

Let us take a look at the first line of our handler (listing 5.19).

Listing 5.19. MaterialsQuantityOnChange procedure (first line)

TabularSectionRow = Items.Materials.CurrentData;

To understand this script, you need to know the execution context. The program context depends on the module where the script is located. In this case, the handler procedure is located in the form module, so we are in the form module context.

Let us review this script line from left to right. What is TabularSectionRow? If something is located to the left of the assignment operator (=), it is either a property that is available directly in this context or a variable.

According to the algorithm described in the previous section, you have to make the following checks:

  1. Is the TabularSectionRow variable declared in the form module?

    Open the form module (to learn how to open a module, see Module types). There is no variable description line (Variable TabularSectionRow;) so this is not a form module variable.
  2. Does the form have the TabularSectionRow attribute?

    Open the form of the GoodsReceipt document and check the form attributes pane located in the upper right part of the form editor (fig. 5.21).


    Fig. 5.21. List of attributes of the GoodsReceipt document form

    You see that this form has a single Object default attribute (displayed in bold). This means that the form does not have the TabularSectionRow attribute.
  3. Does the ManagedForm object have the TabularSectionRow property?

    Let us look at the list of the managed form properties in the Syntax Assistant.

    Open the Syntax Assistant and click the Contents tab.

    A managed form is an interface object of a managed application, so expand the Interface (managed) / Managed form section, then expand the ManagedForm object and its Properties (fig. 5.22).


    Fig. 5.22. List of ManagedForm object properties in the Syntax Assistant

    The properties are sorted alphabetically. You can see that there is no TabularSectionRow property among them.
  4. Does the form extension have the TabularSectionRow property?

    You know that the default form attribute stores data of the DocumentObject.GoodsReceipt object (see fig. 5.21). This means that the properties and methods of the 1C:Enterprise script object Managed form extension for documents (Syntax Assistant / Interface (managed) / Managed form / Managed form extension for documents) are available in the form module. Let us review them (fig. 5.23).


    Fig. 5.23. List of properties of the managed form extension for documents in the Syntax Assistant

    You can see that there is no TabularSectionRow property among them.
  5. Does the TabularSectionRow global context property exist?

    Open the global context properties in the Syntax Assistant (fig. 5.24).

    Fig. 5.24. List of global context properties in the Syntax Assistant

    You can see that there is no TabularSectionRow property among them.

    The TabularSectionRow expression also cannot be the name of a nonglobal common module because its procedures should be called using a dot (TabularSectionRow.).

    This expression also cannot be an exported procedure of a global common module because in this case, one would call the procedure as TabularSectionRow() instead of assigning anything to it.
  6. Does the managed application module contain the TabularSectionRow exported variable?

    Open the managed application module (to learn how to open a module, see Module types). There is no variable description line (Variable TabularSectionRow Export), so this is not a variable of a managed application module.

Now you see that the TabularSectionRow expression is a local variable of the MaterialsQuantityOnChange procedure. During the script execution, a value is assigned to the variable. The 1C:Enterprise script type system allows assigning a value of any type. If a variable is local, i.e. it is only used in the context of this particular procedure, it does not require explicit declaration. The variable is declared when it is first used.

To the right of the assignment operator, you can see the Items.Materials.CurrentData expression. To learn the meaning of Items, let us use the same algorithm as with the TabularSectionRow local variable.

  1. Is the Items variable declared in the form module? No.
  2. Does the form have the Items attribute? No.
  3. Does the ManagedForm object have the Items property?

    Let us look at the list of properties of the ManagedForm object again. There is the Items property among them, so Items is one of the managed form properties. To learn its meaning, double-click it (fig. 5.25).

     
    Fig. 5.25. Description of the Items property of the ManagedForm object in the Syntax Assistant

    The bottom pane of the Syntax Assistant window displays the description of the selected property. This description states that the Items property contains the FormAllItems object that stores a collection of all form controls.

    To learn its meaning, click the FormAllItems link. This opens the description of the FormAllItems collection (fig. 5.26).

     
    Fig. 5.26. Description of the FormAllItems collection in the Syntax Assistant

Note. The Syntax Assistant tree above is not changed. To locate the tree branch that stores the current topic, in the Syntax Assistant, click the Find current element in the tree button  above the object description pane.

This collection contains the controls available in a managed form. You can access an item by its name.

So now you know what Items mean. The next word is separated from Items by a dot: Items.Materials. The collection has a <Control name> property, so Materials is a form control name. Let us look at the structure of form controls. Open the GoodsReceipt document form and look at the form controls pane located in the upper left part of the form editor (fig. 5.27).

 
Fig. 5.27. Structure of form controls of the GoodsReceipt document

The form controls include the Materials table. If you open the property palette of this table, you can see that its title is Properties: Table (fig. 5.28). 

 
Fig. 5.28. Property palette of a table form control

It means that this form control is a table, so we need an object of the FormTable collection. To learn its meaning, click the FormTable link (see fig. 5.26). You will see a list of properties of the FormTable object. The properties are sorted alphabetically (fig. 5.29).

 
Fig. 5.29. List of properties of the FormTable object in the Syntax Assistant

So now you know what Items.Materials mean. The next word is separated from Items.Materials by a dot: Items.Materials.CurrentData. Scroll through the list of managed form table properties to find the CurrentData property. It is one of the properties of the FormTable object. To learn its meaning, double-click it (fig. 5.30).

 
Fig. 5.30. Description of the Current Data property of the FormTable object in the Syntax Assistant

The bottom pane of the Syntax Assistant window displays the description of the selected property. This description states that the CurrentData property contains the FormDataStructure object that contains data stored in the current table row.

So once the first line of the handler (TabularSectionRow = Items.Materials.CurrentData;) is executed, the TabularSectionRow variable contains an object of the FormDataStructure type.

Now let us review the next line of the handler (listing 5.20).

Listing 5.20. MaterialsQuantityOnChange procedure (second line)

TabularSectionRow.Total = TabularSectionRow.Quantity * TabularSectionRow.Price;

It is reasonable to suggest that Total, Quantity, and Price are properties of the FormDataStructure object that is recorded to the TabularSectionRow variable during the execution of the first line. To learn its meaning, click the FormDataStructure link (see fig. 5.30, 5.31).

 
Fig. 5.31. Description of the FormDataStructure object in the Syntax Assistant

The description of this object states that you can use the FormDataStructure object to access the data of a specific tabular section column using the column name as the object property. So using the expression TabularSectionRow.Total you access the data stored in the Total column of the current table row. And the product of data in the Quantity column and data in the Price column is recorded to the Totals column.

Next page: Method #2

Be the first to know tips & tricks on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.