1C:Enterprise 8.3. Practical Developer’s Guide. Lesson 15 (2:50). Charts of characteristic types. Modifying configuration objects

Modifying configuration objects

So you have created new configuration objects and defined their basic properties required to implement your task.

But you will further see that you are not fully happy with some properties. In fact, you can never foresee everything in advance in the development process. Often some shortages only become obvious at run time. So when you review some preliminary results in 1C:Enterprise mode, it is important to be able to understand shortages and correct them on the fly.

This is why during this lesson we will demonstrate a backward development process. This is a valuable experience that we think will be very useful for you.

  • Run 1C:Enterprise in the debug mode.

    The purpose of this run is checking the interaction between the logically connected configuration objects: MaterialsAndServices catalog, MaterialOptions catalog, MaterialProperties chart of characteristic types, and MaterialPropertyValues information register.

    Note that you have not specified any subsystems for these objects. This is because displaying these objects outside of the logical connections between them has no particular sense. Since you have defined the catalog owners, the master information register dimension, and so on, the required objects are automatically added to the navigation panels of their owners as subordinate data.

    So ignore the system message stating that the created objects are not included into any subsystems.

The MaterialOptions catalog

The MaterialPropertyValues information register

In 1C:Enterprise mode

Now you need to create the property sets and the characteristics that form the property sets for specific materials. As we mentioned earlier, the property sets are stored in the MaterialOptions catalog, which is subordinate to the MaterialsAndServices catalog.

Let us create a set of properties for the Power supply cable item.

  1. In the Inventory section, open the Materials and services catalog, expand the Materials group, expand the Miscellaneous group, and double-click the Power supply cable item.

    Since the MaterialsAndServices catalog is the owner of the MaterialOptions catalog, the form navigation panel contains the link for switching to the subordinate list. This list contains only the items related to the MaterialsAndServices item being edited.
  2. Click Material options.

    This opens the list of material property sets (fig. 15.13).

    Lesson 15 (2:50). Charts of characteristic types / Modifying configuration objects / The MaterialOptions catalog / In 1C:Enterprise mode
    Fig. 15.13. List of material options

    We are not quite happy with the material options form that is opened because the Code and Owner columns are obviously not needed.

    The material option code is generated automatically for each new material and is meaningless for a user.

    The material option owner name is displayed in the form title and is a nonsense in the list as well.

    To hide these columns, you have to create a MaterialOptions list form and specify that during the form opening it checks where it is opened from (you can check this using the value in the Filter form parameter).

    If filter by owner is in effect (the form is opened from the materials and services list), let us hide the Code and Owner columns.

    But if the form is opened from any other location, these columns may be needed so it would not be correct to simply remove them from the form.

    Since the form is created on the server, you should do it in the OnCreateAtServer form event handler.

In Designer mode

Let us eliminate the shortages of the list form.

  1. In Designer, open the editor of the MaterialOptions catalog configuration object.
  2. On the Forms tab, in the List field, click the Open Lesson 15 (2:50). Charts of characteristic types / Modifying configuration objects / The MaterialOptions catalog / In Designer mode button (fig. 15.14).

    Lesson 15 (2:50). Charts of characteristic types / Modifying configuration objects / The MaterialOptions catalog / In Designer mode
    Fig. 15.14. Creating a default list form
  3. In the wizard window that is opened, click Finish.

    This creates the default list form.

    Unlike the automatically generated form, the form created by the wizard does not include the Owner field. So your task is getting even simpler as you only need to hide the Code field.
  4. In the upper left pane of the form editor window, on the Elements tab, double-click the Form item.

    You have to double-click this item because the event that you need belongs to the entire form. This opens the form property palette.
  5. Scroll through the list of form properties to locate the OnCreateAtServer event and click its Open Lesson 15 (2:50). Charts of characteristic types / Modifying configuration objects / The MaterialOptions catalog / In Designer mode button (fig. 15.15).

    Lesson 15 (2:50). Charts of characteristic types / Modifying configuration objects / The MaterialOptions catalog / In Designer mode
    Fig. 15.15. Creating OnCreateAtServer form event handler

    This creates the OnCreateAtServer form event handler in the form module.
  6. Add the script shown in listing 15.1 to the event handler.

    Listing 15.1. OnCreateAtServer() form event handler

    If Parameters.Filter.Property("Owner") Then
        Items.Code.Visible = False;
    EndIf;
    Let us review this code.

    Parameters is a property of the managed form where the module belongs. Using this property, you get the object that contains a collection of form parameters.

    The Filter item of this collection is called by its name. Using the Property() method of the filter item structure, you define whether a filter by the Owner field is applied.

    If the filter is applied, you set the Code field visibility to False, which hides the field. Here Items is a managed form property that provides access to all form items.

In 1C:Enterprise mode

Let us test the changes.

  1. Run 1C:Enterprise in the debug mode.

    The material options form should look as shown in fig. 15.16.

    Lesson 15 (2:50). Charts of characteristic types / Modifying configuration objects / The MaterialOptions catalog / In 1C:Enterprise mode
    Fig. 15.16. List of material options

    You see that you have achieved the goal: where in the fig. 15.13 you had three columns, now you only have one Description column.
  2. Click Create to create a set of properties for the material.

    This opens the MaterialOptions catalog item form (fig. 15.17).

    Lesson 15 (2:50). Charts of characteristic types / Modifying configuration objects / The MaterialOptions catalog / In 1C:Enterprise mode
    Fig. 15.17. MaterialOptions catalog item form

    This form is generated automatically. But there are still some shortcomings:
    • The form title should be in the singular.
    • The Code and Owner fields are not needed.
    • The command for switching to subordinate data should be renamed into something more clear.
    Let us return to Designer to correct this.

In Designer mode

Let us rename the form title so that it is clear that the form is intended for creating a single material option.

  1. In Designer, open the editor of the MaterialOptions catalog configuration object.
  2. On the Main tab, in the Object presentation field, enter Material option (fig. 15.18).

    Lesson 15 (2:50). Charts of characteristic types / Modifying configuration objects / The MaterialOptions catalog / In Designer mode
    Fig. 15.18. Specifying object presentation

    This property will be used in the 1C:Enterprise interface as the title of the catalog item form.

    Then you need to remove the Code and Owner fields from the form.
  3. On the Forms tab, in the Item field, click the Open Lesson 15 (2:50). Charts of characteristic types / Modifying configuration objects / The MaterialOptions catalog / In Designer mode button and click Finish.

    This creates the default item form.
  4. In the upper left pane of the form editor window, on the Elements tab, click Code and click Delete Lesson 15 (2:50). Charts of characteristic types / Modifying configuration objects / The MaterialOptions catalog / In Designer mode, and then repeat this procedure for Owner (fig. 15.19).

    Lesson 15 (2:50). Charts of characteristic types / Modifying configuration objects / The MaterialOptions catalog / In Designer mode
    Fig. 15.19. Deleting form controls

    So the only catalog attribute remaining in the form is Description. Let us change its presentation.
  5. In the MaterialOptions catalog configuration object editor, on the Data tab, click Standard attributes and double-click Description.
  6. In the property palette that is opened, in the Synonym field, enter Name.

    Finally, the title of the Material option form and the title of its subordinate data Material property values do not look good together (see fig. 15.17). This subordinate data consists of records of the MaterialPropertyValues register that can be opened from the item form.
  7. Open the editor of the MaterialPropertyValues information register configuration object and then, on the Main tab, in the List presentation field, enter Material option details (fig. 15.20).

    Lesson 15 (2:50). Charts of characteristic types / Modifying configuration objects / The MaterialOptions catalog / In Designer mode
    Fig. 15.20. Specifying list presentation for a register

    This value will be used in the 1C:Enterprise interface as the title of the register list form.

In 1C:Enterprise mode

Let us test the changes.

  1. Run 1C:Enterprise in the debug mode.
  2. In the Inventory section, open the Materials and services catalog, expand the Materials group, expand the Miscellaneous group, and double-click the Power supply cable item. 
  3. In the item form, click Material options.

    This opens the list of material property sets, which is empty for now.
  4. Click Create.

    Now we are happy with everything about the material options form.

In 1C:Enterprise mode

Let us create a material option.

  1. In the Description field, enter White cables (fig. 15.21).

    Lesson 15 (2:50). Charts of characteristic types / Modifying configuration objects / The MaterialPropertyValues information register / In 1C:Enterprise mode
    Fig. 15.21. Material options catalog item form
  2. Click Material option details.

    This opens the form where you can edit the material option content.

    Tip. The reader feedback shows that one might encounter the following issue at that point: the Material option details command, which opens the related MaterialPropertyValues register records, is not available in the form navigation panel. This is probably because you forgot to set the Master property for the PropertySet register dimension, which has the CatalogRef.MaterialOptions type.

    Once a register dimension becomes a master dimension, the link that opens the list of register records that have the reference to the current material option in their PropertySet dimension is added to the form navigation panel.

    Since the material option has not been recorded yet, you are prompted to record the data.
  3. Confirm that you want to record the data (fig. 15.22).

    Lesson 15 (2:50). Charts of characteristic types / Modifying configuration objects / The MaterialPropertyValues information register / In 1C:Enterprise mode
    Fig. 15.22. Confirmation of data recording

    This opens the automatically generated list form of the MaterialPropertyValues register (fig. 15.23).

    Lesson 15 (2:50). Charts of characteristic types / Modifying configuration objects / The MaterialPropertyValues information register / In 1C:Enterprise mode
    Fig. 15.23. Material option details register list form

    We are not happy with everything in the form either:
    • The Property type column should better be renamed.
    • The Property set column is not needed.
    Let us return to Designer and eliminate the shortages of the list form.

In Designer mode

Let us rename the Property type column to Property.

  1. In Designer, open the editor of the MaterialPropertyValues information register configuration object.
  2. On the Data tab, open the property palette for the PropertyType dimension and set its Synonym to Property (fig. 15.24).

    Lesson 15 (2:50). Charts of characteristic types / Modifying configuration objects / The MaterialPropertyValues information register / In Designer mode
    Fig. 15.24. Specifying register dimension synonym

    Since the register has the PropertySet master dimension with the CatalogRef.MaterialOptions type, the Property set field is not needed because the owner of this property set is displayed in the form title.

    Therefore, in the OnCreateAtServer event handler of the register list form, let us hide the Property set column for scenarios when the form is opened with a filter by this field applied (in other words, when the register list form is opened from the item form of the MaterialOptions catalog).
  3. On the Forms tab, in the List field, click the Open Lesson 15 (2:50). Charts of characteristic types / Modifying configuration objects / The MaterialPropertyValues information register / In Designer mode button and then click Finish.

    This creates the default list form.
  4. Create the OnCreateAtServer event handler and add the script shown in listing 15.2 to the handler.

    Listing 15.2. OnCreateAtServer() form event handler

    If Parameters.Filter.Property("PropertySet") Then
        Items.PropertySet.Visible = False;
    EndIf;
    This script is similar to that provided in listing 15.1, so it does not require any further comments.

In 1C:Enterprise mode

Let us test the changes.

  1. Run 1C:Enterprise in the debug mode and open the Material option form (fig. 15.25).

    Lesson 15 (2:50). Charts of characteristic types / Modifying configuration objects / The MaterialPropertyValues information register / In 1C:Enterprise mode
    Fig. 15.25. Material option details register list form

    Let us add a material option details record.
  2. Click Create.

    This opens an automatically generated MaterialPropertyValues register record form (fig. 15.26).

    Lesson 15 (2:50). Charts of characteristic types / Modifying configuration objects / The MaterialPropertyValues information register / In 1C:Enterprise mode
    Fig. 15.26. Material property values register record form

    But there are still some shortcomings:
    • The form title should be in the singular.
    • The Property set column is not needed.
    Let us return to Designer to correct this.

In Designer mode

Let us rename the form title so that it is clear that the form is intended for creating a single property in material option details and for specifying the property value.

  1. In Designer, open the editor of the MaterialPropertyValues information register configuration object.
  2. On the Main tab, in the Record presentation field, enter Property and value (fig. 15.27).

    Lesson 15 (2:50). Charts of characteristic types / Modifying configuration objects / The MaterialPropertyValues information register / In Designer mode
    Fig. 15.27. Specifying register record presentation

    This property will be used in 1C:Enterprise interface as the title of the register record form.

    Then let us remove the PropertySet field from the form.
  3. On the Forms tab, in the Record field, click the Open Lesson 15 (2:50). Charts of characteristic types / Modifying configuration objects / The MaterialPropertyValues information register / In Designer mode button and then click Finish.

    This creates the default record form.
  4. In the upper left pane of the form editor window, click the Elements tab, then click PropertySet, and click Delete Lesson 15 (2:50). Charts of characteristic types / Modifying configuration objects / The MaterialPropertyValues information register / In Designer mode.

In 1C:Enterprise mode

Let us test the changes.

  • Run 1C:Enterprise in the debug mode and open the MaterialPropertyValues register record form.

    The form should look as shown in fig. 15.28.

    Lesson 15 (2:50). Charts of characteristic types / Modifying configuration objects / The MaterialPropertyValues information register / In 1C:Enterprise mode
    Fig. 15.28. Material option details register record form

Leave a Reply

Your email address will not be published. Required fields are marked *

1C:Enterprise Developer's Community