1C:Enterprise 8.3. Practical Developer’s Guide. Lesson 27 (2:10). Form development techniques. Attribute fill check

Attribute fill check

Attributes of configuration objects support both automatic and 1C:Enterprise script-based fill checks. Instead of form level, this check is performed at the attribute property level or in the module of the object where the attribute belongs. This ensures that the fill check is performed in all forms that include the attribute.

Automatic fill check

1C:Enterprise script-based fill check

In Designer mode

Let us implement a fill check in the Services document configuration object. Suppose that you want to ensure that the PropertySet attribute of the document tabular section is filled.

  1. Open the configuration object editor for the Services document.
  2. Open the property palette of the PropertySet tabular section attribute and set the Fill check property to Display error (fig. 27.34).

    Lesson 27 (2:10). Form development techniques / Attribute fill check / Automatic fill check / In Designer mode
    Fig. 27.34. The Fill check property of the PropertySet attribute

    This value defines that when a document is written, the platform checks whether this attribute value is empty. And if it is empty, it displays an error message and does not save the document.

In 1C:Enterprise mode

Let us test the changes.

  1. Start 1C:Enterprise in the debug mode.
  2. Open the Services document #CI0000001.

    The tabular section of the document contains two rows, both having empty values in the Property set column.
  3. Click Post.

    Instead of posting, two error messages are displayed and the changes are not saved (fig. 27.35).

    Lesson 27 (2:10). Form development techniques / Attribute fill check / Automatic fill check / In 1C:Enterprise mode
    Fig. 27.35. Error messages

In Designer mode

Your application logic might require custom attribute fill checks. In this scenario, if the Fill check property of an attribute is set to Display error, you can use 1C:Enterprise script to remove the attribute from the array of attributes to be checked and then implement a custom check. Alternatively, you can add an attribute that is not normally checked to the array of attributes to be checked.

1C:Enterprise-based fill checks for configuration objects are executed in FillCheckProcessing() event handlers that are located in object modules. A FillCheckProcessing event handler is called every time an object form is saved or a document is posted. Fill checks for values that are entered interactively must be performed in this event handler instead of when the object is being saved.

  • Open the Services document module and add the procedure shown in listing 27.4.

    Listing 27.4. FillCheckProcessing event handler

    Procedure FillCheckProcessing(Cancel, AttributesToCheck)
        Index = AttributesToCheck.Find("MaterialsAndServices.PropertySet");
        If Index <> Undefined Then
        Index = 0;
        For Each CurRowMaterialOrService In MaterialsAndServices Do
            If CurRowMaterialOrService.MaterialOrService.MaterialServiceType =
                Enums.MaterialServiceTypes.Material Then
                If Not ValueFilled(CurRowMaterialOrService.PropertySet) Then
                    Message = New UserMessage();
                    Message.Text = "The ""Property set"" column is not filled in row "
                        + String(Index+1) + " of the ""Materials and services"" list";
                    Message.Field = "MaterialServiceList[" + String(Index) + "].PropertySet";
                    Cancel = True;
            Index = Index + 1;
    First the procedure searches the AttributesToCheck array for the PropertySet tabular section attribute. This array is passed to the event handler and contains all the attributes that have the Fill Check property set to Display error. If the PropertySet attribute is found, it is deleted from the array because a custom check is performed for that attribute.

    Next the procedure iterates through the document tabular section rows and generates an error message for each tabular section row that has an empty value in the PropertySet column.

    Setting the Cancel parameter to True means that the document is not posted if at least one row that contains a material has an empty PropertySet value. If you comment this script line out, error messages will be displayed but the document will be posted.

    To simplify the example, we used the MaterialsOrServices.MaterialOrService.MaterialServiceType call, though using a query is optimal here. This issue has been discussed in detail in lesson 14 so we will not discuss it here again.

In 1C:Enterprise mode

Let us test the changes.

  1. Start 1C:Enterprise in the debug mode.
  2. Open the Services document #CI0000001 and click Post.

    An error message is displayed for the second row of the tabular section (fig. 27.36).

    Lesson 27 (2:10). Form development techniques / Attribute fill check / 1C:Enterprise script-based fill check / In 1C:Enterprise mode
    Fig. 27.36. Error message upon posting a document

You can also use 1C:Enterprise script to add an attribute to the array of attributes that are checked (listing 27.5).

Listing 27.5. Adding an attribute to the array of attributes that are checked


Leave a Reply

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


1C:Enterprise Developer's Community