Understanding "empty" values





There are no "empty" values in 1C:Enterprise 8.

The Undefined value (which has Undefined type) is available instead. It is mostly used as a default value for composite objects, such as attributes or value table columns. If an attribute can store values of multiple types, its default value is Undefined. You can assign the Undefined value to a composite attribute to indicate that it does not store any values of other available types. A variable declared in a module also has the Undefined type until it is assigned a value. Note that TypeDescription objects that contain multiple types implicitly include the Undefined type too (because they can have Undefined value). Therefore, Undefined means the absence of value of any other type.

The Null value (which has Null type) is also available. It indicates the absence of a value in a selection retrieved from a database. For example, if you perform left or right join operations, record fields that are not selected have Null values. Also, if an attribute of a hierarchical catalog is only required for regular items and not required for groups (as specified in metadata), it has the Null value for groups. Similarly, attributes available only for groups have Null values for regular items.

Note that both Undefined and Null values have types (which match their names) and are only used in situations described earlier in this article. Do not use them as "empty" values of any other types.

Most types have default values, which are automatically assigned to objects of those types, such as attributes or value table columns. For example, 0 for numbers; an empty string for strings; or the date reference point ('00010101') for dates.

For types that represent references to database objects, empty reference values are available. You can get them using the EmptyRef() method of the corresponding manager. They are used as default values for the corresponding types. Note that if an attribute has composite type that includes a "reference to database object" type, you can assign the Undefined value to the attribute or you can assign the corresponding empty reference value to itthese two values are different. Choose one of these values depending on your application logic.

For example, an attribute can have two reference type values and it is evident from other attribute values that it must store a value of certain type (one of these two), but the user has not yet chosen a specific reference. Then you might want to assign an empty reference value of the required type. This allows a user to enter a value of the required type in the input field. In another scenario, if other attribute values imply that this attribute should not be filled at all, assign the Undefined value to it.

1C:Enterprise 8 includes the "unfilled value" concept, which is used in various service features. For example, you can set the No Empty Values parameter of a register dimension to True, and then the platform will automatically check whether the dimension is filled during each write operation. You can also use the AutoMarkIncomplete property (to set automatic underlining of unfilled fields) and the AutoChoiceIncomplete property (to start automatic value selection in an unfilled field).

All of the fill checks are performed according to the same rules. A value is considered unfilled if it is equal to the default value for its type. For example, a zero number, an empty string, or an empty reference to a catalog item are considered unfilled values.

Note that the IsEmptyString() function does not check whether a string value is equal to the default value. It checks whether a string contains significant characters. Space, nonbreaking space, and a few more characters are considered insignificant.


Comments
0
Add comment