1C allows you to greatly simplify bookkeeping or simply manage any organization, whether it is a small shop or a large enterprise. The program is a large database management system. In order not to get confused in all this, you need to be able to perform various simple actions and understand the essence. Next, you will understand how to check the type of a value in a request in 1C, as well as what they are, in general, and how to distinguish between them.

Value types

1C: The enterprise has included a special function in the new versions (platform 8.2). Using it, you can add any special parameters to any names, elements of the data system. This was done to make it easier to edit the system and add new elements there. This function is just called "Value Type".

In fact, this is one of the basic concepts that contains most programming languages. It can be used to classify various data. For example: dates, numbers, strings, links. These are just basic classifications. There may be many more. Let's say if you enter information about cities into your system, you can use: mainland, country, district, etc.

Examination

You can check a particular field using the query language. To be more precise, its functions: VALUE TYPE. That is, if we want to find out what kind of information the cell of interest contains, we must use the command.

VALUETYPE(Value) = TYPE(String)

In the example above, we have defined, using the command, simplest form. Another request validation example:

The documents

There are quite a few types themselves, users can get by with both the initial ones and enter their own in order to improve information base. Here is some of them.

  • DocumentLink. It is used for convenient storage of references to various objects within other parts of the system.
  • DocumentObject - editing documents.
  • DocumentSelection - sorting objects from the database.

In addition, there are special terms that characterize any data:

  • the form;
  • line;
  • boolean
  • number;
  • the date;
  • array;
  • checkbox;
  • picture.

This is just a part of them. Any object can only be something from this list. boolean - special parameter, which takes two values: true or false. There are also special tags that allow you to adjust the request: when, where, how, otherwise, etc. They set the program behavior algorithm. 1C is distinguished by the fact that these words here, like everything else, can be entered in Russian.

It is important to understand that all this will be perceived by beginners and non-professionals as a Chinese letter. To understand what is at stake and use 1C effectively, you need to know the basics of programming. In general, it will be quite easy to check the type in a request in the 1C program, in comparison with other actions.

Attention! Here is a trial version of the lesson, the materials of which may not be complete.

Login as a student

Sign in as a student to access school content

1C 8.3 query language for beginner programmers: functions and operators for working with types (VALUE TYPE, TYPE, REFERENCE, IS NULL, EXPRESS)

Let's remember that each attribute (property, field) of a reference book, document or any other application object has its own type . And we can see this type in the configurator:

The query language has whole class functions and operators for working with attribute types. Let's take a look at them.

VALUETYPE function

This function takes one parameter (value) and returns its type. For the props described in the picture (above) Taste directory Food will return the following:

Now let's take a look at the props. Distinguishing Feature at the directory Cities:

You can see that this prop can be one of several types: Line, Directory. Tastes, Reference.Colors. This type of details is called COMPOSITE.

If we try to fill in the value of such an attribute in 1C:Enterprise mode, the system will ask us what type the input value will be:

And only after our choice will allow you to enter the value of the selected type.

Thus, directory elements of the same type ( Directory.Cities) will be able to store in the same attribute ( Distinguishing Feature) values different types(String, Colors or Flavors).

You can verify this for yourself by clicking on the elements of the directory Cities in 1C:Enterprise mode. You are reading a trial version of the lesson, full lessons are located.

Here the feature value is a reference element Tastes:

Here the line:

And here, in general, an element of the directory Colors:

These are the possibilities that a composite data type opens up for us!

I wonder how the function will behave VALUETYPE on props DistinctiveElement, which has a composite data type:

This is already very interesting. Let's deal with each line separately.

The feature value type for the Russia element is NULL. This is the first time we have encountered this type. Values of this type are used solely to determine the missing value when working with the database.

It is, because the element Russia is a group, and not an ordinary element of the directory Cities, so it has no field Distinguishing Feature. And the type of the missing value, as we read above, is always equal to NULL.

The value type of the distinguishing feature for Perm is Tastes. So it is, because the value of the distinguishing feature scored in the database for the city of Perm is a link to the directory element Tastes.

For Krasnoyarsk, the feature type is equal to Colors, because the value selected in the database is a reference to a dictionary element Colors.

For Voronezh, the feature type is equal to Line, because the value entered in the database is a normal string.

India is a group again, so the meaning is missing. And the type of the missing value, as we remember, is NULL.

And here's the thing. If you go to the directory element Cities with the name Sao Paulo, you will see that the field Distinguishing Feature completely unfilled. It is empty. BUT all empty fields of a composite type have a special meaning UNDEFINED .

FROM UNDEFINED we also meet for the first time. Meaning UNDEFINED used when you want to use an empty value that does not belong to any other type. This is just our situation. A value type UNDEFINED, as you probably already guessed, is equal to NULL.

Function TYPE

It takes only one parameter - the name of the primitive type ( LINE, NUMBER, THE DATE, BOOLEAN), or the name of the table whose reference type you want to get.

The result of this construction will be a value of type Type for the specified type.

Sounds hazy, doesn't it?

Let's look at the application of this design and everything will immediately fall into place.

Suppose we want to select all directory entries Cities, which have a composite attribute Distinguishing Feature has a value of type LINE:

Now let's select all records that have attribute values Distinguishing Feature are references to reference elements Colors(table Reference.Colors):

Retreat

As you remember, some elements of the directory Cities do not have props Distinguishing Feature. Function VALUETYPE for such elements gives NULL.

How it is possible to make selection of such elements in request? There is a special logical operator for this. IS NULL(not to be confused with the function IS NULL which we will discuss below). You are reading a trial version of the lesson, full lessons are located.

Here is an example of its use:

Excellent. But you noticed that there is no Sao Paulo element here, props value type Distinguishing Feature which was also issued NULL. Why did it happen?

And the thing is that the situation for groups (Russia, India, Brazil), for which filling in the details Distinguishing Feature impossible in principle, since they do not have it at all, differs from the situation for the Sao Paulo element, for which filling in the attribute is possible, but it is simply not filled in and, as we remember, is equal to the special value UNDEFINED.

To select all records that have props Distinguishing Feature present but not filled, another construct should be used:

But comparing with UNDETERMINATED to define empty (not populated) props will only work for composite types.

By the way, at logical operator IS NULL negation form is as follows:

Boolean operator REFERENCE

For example, let's choose from the directory Cities only those records that have the value of a composite attribute Distinguishing Feature are a reference to a reference element Tastes:

As you remember, we could solve the same problem using VALUETYPE and TYPE OF:

Function ISNULL

The function is intended to replace the value NULL to another value.

We remember that the value NULL is returned if the requested attribute (field, property) does not exist.

Like props Distinguishing Feature for directory groups Cities:

Function IS NULL will help us output another value if this value is equal to NULL. You are reading a trial version of the lesson, full lessons are located. Let in this case it will be the line "There is no such attribute!":

It turns out that if the first parameter of the function IS NULL not equal NULL, then it returns. If it is NULL, then the second parameter is returned.

EXPRESS function

This function is only for fields that have a composite type. A great example of such a field is the property Distinguishing Feature for directory elements Cities.

As we remember, composite fields can be one of several types specified in the configurator.

For field Distinguishing Feature such valid types are LINE, Reference.Colors and Directory. Tastes.

Sometimes it becomes necessary to cast the values ​​of a composite field to a particular type.

Let's list all field values Distinguishing Feature to type Reference.Colors:

As a result, all element values ​​that had the type Reference.Colors, remained filled and turned out to be reduced to the specified type. All values ​​of other types ( LINE, Directory. Tastes) are now equal NULL. This is the peculiarity of type casting using the function EXPRESS.

You can cast a type either to a primitive type ( BOOLEAN, NUMBER, LINE, THE DATE) or to a reference type. You are reading a trial version of the lesson, full lessons are located. But the type to which the cast is made must be included in the list of types for this composite field, otherwise the system will generate an error.

Take the test

Start test

1. Choose the most correct statement

2. Attributes that can take values ​​of one of several types are called

3. To determine the type of attribute value, the function is suitable

4. Unfilled composite type attributes matter

Home For Beginner Developers Learn to Program

How to check the value type of a document, directory?

First, in the built-in language, several types are implemented to work with one application object.

For example, tasks that in 1C:Enterprise 7.7 were solved by the type Document solved now by several types. They are divided according to their purpose.

Type of DocumentObject used to write and delete individual documents.

Type of DocumentSelection is used to iterate over the documents stored in the database.

There are other data types designed to work with a document. When writing modules, those types are used that are necessary for solving specific problems.

Secondly, there are no two concepts in the built-in language - Type of and View. Each configuration object has its own set of types used in the built-in language to work with the application object it describes. That is, when using the configuration, there will not be such a type as DocumentLink, and there will be concrete types, for example, DocumentReference.Invoice, DocumentObject.Invoice, DocumentReference.Invoice, etc.

In addition, for manipulating types, not their string names are used, but a special type Type of. Type value Type of can be obtained by the function Type of() A that takes the type name as a parameter.

To check the type of a variable's value, you need to determine its type with a function ValueType() and use the function Type of() to get a type by name.

For example:

Defined types are a new 1C metadata object that appeared in platform version 8.3. The object has an auxiliary character. Let's consider what are the defined types and tasks that this object can solve.

Defined are new data types, the set of which is defined by the application solution developer. It consists of several valid types. Such a data type can be the type of any configuration attribute, except for the type being defined and the object " ".

Get 267 1C video lessons for free:

Setting

There are not so many settings for this object:

Those. in addition to the name and synonym in 1C, the defined types have only a set of object types.

An example of the use of defined types in 1C 8.3

There are many applications for this object.

Examples of using:

  • you can describe in the configuration attributes that refer to the data that will be determined when embedding the fragment in a specific configuration;
  • assign one type of defined data to a certain set of event subscriptions, when changing the set of types for all subscriptions, the source will change dynamically;
  • use as an alternative to the plan of types of characteristics

and much more.

If you are starting to learn 1C programming, we recommend our free course(do not forget