1C:Enterprise 8.3. Practical Developer’s Guide. Lesson 10 (0:40). Enumerations. Custom presentations for materials and services

Custom presentations for materials and services

Let us use the MaterialServiceType attribute for specifying custom presentations for materials and services in 1C:Enterprise interface.

Material and service presentations are displayed in all fields that refer to MaterialsAndServices catalog items. This includes document tabular section fields, information register fields, accumulation register fields, and more.

As with any catalog item, the default  material or service presentation is defined by the Default presentation property. The default property value is As description (fig. 10.4).

Lesson 10 (0:40). Enumerations / Custom presentations for materials and services
Fig. 10.4. Default presentation property of a catalog

That is why the Material or service column in the document tabular section shows the material or service names instead of references (fig. 10.5).

Lesson 10 (0:40). Enumerations / Custom presentations for materials and services
Fig. 10.5. Services document

Let us modify the view of references to MaterialsAndServices catalog items so that they display the item type: material or service.

In Designer mode

The generation of configuration object presentations consists of two stages: first, defining the attributes that affect the presentation, and then the generation itself. You can use the following object manager event handlers for this: PresentationFieldsGetProcessing and PresentationGetProcessing.

  1. In Designer, in the configuration object tree, right-click the MaterialsAndServices catalog and click Open manager module.
  2. Add the procedures from listings 10.1 and 10.2 to the manager module.

    Listing 10.1. Procedure PresentationFieldsGetProcessing()

    Procedure PresentationFieldsGetProcessing(Fields, StandardProcessing)
        StandardProcessing = False;

    Listing 10.2. Procedure PresentationGetProcessing()

    Procedure PresentationGetProcessing(Data, Presentation, StandardProcessing) 
        StandardProcessing = False;
        If ValueIsFilled(Data.MaterialServiceType) Then
            Presentation = Data.Description + " (" + Lower(String(Data.MaterialServiceType)) + ")";
            Presentation = Data.Description;

Now let us examine this script.

The PresentationFieldsGetProcessing handler describes the attributes that affect the document presentation. First, the handler sets the StandardProcessing parameter to False, and then it adds the required catalog attributes to the Fields array. Note that if StandardProcessing is not set to False, the Fields array contains the attributes used to generate the default object presentation (in this case it is the Description attribute).

The PresentationGetProcessing handler describes the generation of the Presentation parameter based on the array of fields specified in the previous handler. The data required to generate the presentation is passed in the Data parameter that has Structure type. First, StandardProcessing is set to False, and then the material or service presentation is generated by adding the type enclosed in parentheses to the description. Note that if StandardProcessing is not set to False, the platform attempts to generate the default object presentation based on the data that is passed to the handler.

In 1C:Enterprise mode

Let us test the changes that you made.

  1. Run 1C:Enterprise in the debug mode.
  2. Open the Services document and ensure that the material or service presentations are generated according to the algorithm that you specified (fig. 10.6).

    Lesson 10 (0:40). Enumerations / Custom presentations for materials and services / In 1C:Enterprise mode
    Fig.10.6. The Services document

You can use this method to set custom presentations not only for catalogs, but also for documents, charts of characteristic types, charts of accounts, and other configuration objects.

Leave a Reply

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

1C:Enterprise Developer's Community