How to set up smartphones and PCs. Informational portal
  • home
  • Errors
  • Type value in 1s request 8.2. How to get the Type (type) of a Document in a request? TYPE in request

Type value in 1s request 8.2. How to get the Type (type) of a Document in a request? TYPE in request

1C allows you to significantly simplify accounting or simply manage any organization, be it a small store 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 value in a request in 1C, as well as what they generally are, as well as 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 or elements of the data system. This was done to make the system easier to edit and add new elements to. 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: continent, country, region, 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 type of information the cell of interest contains, we must use the command.

VALUETYPE(Value) = TYPE(String)

In the example above, we defined the simplest type using the command. Another example of request validation:

Documentation

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

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

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

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

These are just some of them. Any object can only be something from this list. Boolean is a special parameter that 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’s 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 Chinese literacy. To understand what we are talking about and effectively use 1C, you need to know the basics of programming. In general, checking the type in a request in the 1C program will be quite easy in comparison with other actions.

Let's look at the rest now.

Functions for working with strings in 1C queries

There are few functions and operators for working with string data in 1C queries.

Firstly, strings in queries can be added. To do this, use the “+” operator:

Request. Text = "SELECT
" "Line: " " + Source.Name
;

Secondly, you can select part of the line. To do this, use the function SUBSTRUCTION. The function is similar to the built-in 1C language. It has three parameters:

  1. Source string.
  2. The number of the character with which the selected line should begin.
  3. Characters.

Request. Text= "CHOOSE
SUBSTRING("
"Line: " ", 4, 3) AS A Result"; // Result: oka

Function ISNULL

NULL is a special data type on the 1C:Enterprise platform. It is also the only possible value of this type. NULL can appear in queries in several cases: when connecting query sources, if a corresponding value was not found in one of the tables; when accessing the details of a non-existent object; if NULL was specified in the list of query fields (for example, when combining selection results from several tables), etc.

Because NULL is neither null, nor the empty string, nor even a value Undefined, it is often useful to replace it with some more useful data type. This is what the function is designed for. ISNULL.

It has two parameters:

  1. The value being checked.
  2. The value to replace the first parameter with if it turns out to be NULL.

Request. Text= "CHOOSE
ISNULL(Source.Remainder, 0) AS Remainder"
; // If the result of the request is the field remainder = NULL,
// then it will be replaced by 0, and you can perform mathematical operations with it

Functions PERFORMANCE And INTRODUCTIONLINKS

These functions are designed to obtain string representations of various values. That is, they convert references, numbers, booleans, etc. into plain text. The difference between them is that the function PERFORMANCE converts any data types to text (string), and the function INTRODUCTIONLINKS- only links, and returns the remaining values ​​as is, not converted.

Request. Text= "CHOOSE
REPRESENTATION(TRUE) AS Boolean,
REPRESENTATION (4) AS A Number,
REPRESENTATION (Source.Link) AS Link,
REPRESENTATION(DATETIME(2016,10,07)) AS Date"
;
// Boolean = "Yes", Number = "4", Link = "Document Cash receipt order No.... from..."
// Date="07.10.2016 0:00:00"

Request. Text= "CHOOSE
REPRESENTATIONREFERENCE(TRUE) AS Boolean,
REPRESENTATIONREFERENCE(4) AS NUMBER
PRESENTINGLINK(Source.Link) AS Link,
REPRESENTATIONREFERENCE(DATETIME(2016,10,07)) AS Date"
;
// Boolean = TRUE, Number = 4, Link = "Document Cash receipt order No.... from..."
// Date=07.10.2016 0:00:00

Functions TYPE And TYPE VALUES

Function TYPE returns the 1C:Enterprise platform data type.

Request. Text= "CHOOSE
TYPE (Number)
TYPE (String),
TYPE (Document. Expenditure Cash Order)"
;

Function TYPE VALUES returns the type of the value passed to it.

Request. Text= "CHOOSE
VALUES TYPE (5) AS Number,
TYPE ("
"Line" ") AS String,
TYPE (Source.Link) AS Reference
From the Directory.Source AS Source"
;
//Number=Number, String=String, Directory = DirectoryLink.Source

These functions are convenient to use, for example, when you need to find out whether a field received in a request is a value of some type. For example, let’s get the contact information of counterparties from the ContactInformation information register (contacts of not only counterparties, but also organizations, individuals, etc. are stored there):

Request. Text= "CHOOSE

FROM

WHERE
VALUES TYPE(ContactInformation.Object) = TYPE(Directory.Counterparties)"
;

Function MEANING

Function Meaning allows you to use 1C configuration objects directly in a request, without using .

Let's add one more condition to the previous example. You only need to get the phone numbers of your counterparties.

Request. Text= "CHOOSE
ContactInformation.Introduction
FROM
Register of Information. Contact Information HOW Contact Information
WHERE
VALUES TYPE(ContactInformation.Object) = TYPE(Directory.Counterparties)
AND ContactInfo.Type = VALUE(Enum.ContactInfoTypes.Phone)"
;

It should be noted that this function can only be used with predefined values, i.e. with values ​​that can be accessed directly from the configurator. That is, the function MEANING cannot be used with directory elements created by users, but can work with enumerations, with predefined directory elements, with values EmptyLink.

Operator LINK

Operator LINK is designed to check the values ​​received by the request for belonging to a specific reference type. The same task can be accomplished using functions TYPE And TYPE VALUES(which have a wider scope and were discussed above).

For example, the task of choosing the contact information of counterparties could be solved like this:

Request. Text= "CHOOSE
ContactInformation.Introduction
FROM
Register of Information. Contact Information HOW Contact Information
WHERE
ContactInformation.Object LINK Directory.Counterparties"
;

Operator EXPRESS

Operator EXPRESS used in 1C queries in two cases:

  • when you need to change the characteristics of a primitive type;
  • when you need to turn a field with a compound data type into a field with a single type.

Primitive data types include: number, string, date, boolean. Some of these data types have additional characteristics. Type Number has length and precision, type Line - length or unlimited.

Operator EXPRESS allows you to change not the data type, but additional characteristics. For example, he can turn a string with unlimited length into a string with limited length. This can be useful if you need to group query results by such a field. You can't group by fields with an unlimited length, so we convert it to a string with a length of 200 characters.

Request. Text= "CHOOSE
QUANTITY (DIFFERENT Arrival of Goods and Services. Link) AS Link
FROM
Document. Receipt of Goods and Services HOW Receipt of Goods and Services
GROUP BY
EXPRESS(Receipt of Goods and Services. Comment AS ROW (200))"
;

In some cases, queries to fields with a composite data type may not be processed optimally by the 1C platform. This results in longer query times, so it can be useful to convert a compound type to a single type in advance.

Request. Text= "CHOOSE
EXPRESS(Movement of GoodsTurnover.Order AS Document.Customer Order).Date AS Order Date,
Movement of GoodsTurnover.Nomenclature
FROM
RegisterAccumulations.Movement of Goods.Turnover AS Movement of GoodsTurnover
WHERE
Movement of GoodsTurnover.Order LINK Document.Client Order"
;

Operators CHOICE And IS NULL

Operator CHOICE similar to operator IF in the built-in 1C language, but has somewhat reduced functionality.

Let's say we want to receive contact information from the ContactInformation information register and, at the same time, indicate in a separate request field whether it belongs to a counterparty or an individual.

Request. Text= "CHOOSE
ContactInformation.Introduction,
CHOICE
WHEN VALUES TYPE(ContactInformation.Object) = TYPE(Directory.Counterparties)
THEN "
Counterparty "
ELSE CHOICE
WHEN VALUES TYPE(ContactInformation.Object) = TYPE(Directory.Individuals)
THEN "
Individual"
ELSE "Someone else" "
END
END AS OWNER
FROM
Register of Information. Contact Information AS Contact Information"
;

As can be seen from the example, in the design CHOICE there is always a condition after the word WHEN; value applied if the condition is true after the word THEN and the value applied if the condition is not met, after the word OTHERWISE. All three design elements CHOICE are mandatory. Omit element OTHERWISE, the same way as when using the operator IF in the built-in 1C language, it is impossible. Also from the operator CHOICE there is no analogue of the design ELSEIF, but you can invest one CHOICE in another, as was done in our example.

Operator IS NULL used in design CHOICE to compare a query field with type NULL.

Request. Text= "CHOOSE
CHOICE
WHEN THE VALUE IS NULL THEN 0
ELSE Meaning
END"
;

In addition, the operator IS NULL can be used in query conditions, such as in a sentence WHERE.

In this article we want to discuss everything with you 1C query language functions, and query language constructs. What is the difference between function and design? The function is called with parentheses and possible parameters in them, and the construct is written without parentheses. Undoubtedly all structures and functions of the 1C query language make the data acquisition process flexible and multifunctional. These functions and constructs apply to request fields, and some also apply to conditions.

1C Query Language Functions

Because a clear description 1C query language functions is much less common than descriptions of structures, we decided to start looking at functions. Now let's analyze each one separately, describing its purpose, syntax and usage example, so:

1. Function DATE TIME- this function creates a constant field with the "Date" type.

Syntax: DATE TIME(<Год>,<Месяц>,<День>,<Час>,<Минута>,<Секунда>)

Usage example:

2. DATE DIFFERENCE function- returns the difference of two dates in one of the dimensions (year, month, day, hour, minute, second). The measurement is passed as a parameter.

Syntax: DIFFERENCEDATE(<Дата1>, <Дата2>, <Тип>)

Usage example:

Query.Text = "SELECT | DATE DIFFERENCE(DATETIME(2015, 4, 17), DATETIME(2015, 2, 1), DAY) | AS Number of Days";

3. Function VALUE- sets a constant field with a predefined entry from the database, you can also get a null reference of any type.

Syntax: VALUE(<Имя>)

Usage example:

Query.Text = "SELECT //predefined element | VALUE(Currency.Dollar.Catalog.Dollar) AS Dollar, //empty reference | VALUE(Document.IncomingGoodsServices.EmptyReference) AS Receipt, //transfer value | VALUE(Transfer.LegalIndividual. Individual) AS Individual, //predefined account | VALUE(Chart of Accounts.Self-supporting.Materials) AS Account_10" ;

4. SELECT function- we have an analogue of the IF construction that is used in the code, only this one is used in 1C queries.

Syntax: CHOICE WHEN<Выражение>THEN<Выражение>OTHERWISE<Выражение>END

Usage example:

Request.Text = //if the amount is more than 7500, then there should be a discount of 300 rubles, //therefore, if the condition is triggered, then the function //returns the Amount - 300 //otherwise, the request will simply return the Amount "SELECT | SELECT | WHEN PMIncome.Amount > 7500 | THEN PTReceipt.Amount - 300 | ELSE PTReceipt.Amount | END AS AmountDiscounted |FROM | Document.ReceiptofGoodsServices.Goods AS PTReceipts";

5. EXPRESS function- allows you to express a constant field with a specific type.

Syntax: EXPRESS(FieldName AS TypeName)

Usage example:

Query.Text = "SELECT VARIOUS | Sales.Registrar.Number, | SELECT | WHEN Sales.Registrar REF Document.Expense | THEN EXPRESS(Sales.Registrar AS Document.Expense) | ELSE SELECT | WHEN Sales.Registrar REF Document.Implementation | THEN EXPRESS(Sales.Registrar AS Document.Release) | END | ... | END AS Number | FROM | Accumulation Register.Purchases AS Purchases";

Still there is a variant of use of the EXPRESS function in fields of the mixed types where such meet? The simplest example is the “Registrar” for any register. So why might we need to qualify the type in the registrar? Let's consider the situation when we select the "Number" field from the registrar, from which table will the number be selected? The correct answer of all! Therefore, in order for our query to work quickly, we must specify an explicit type using the EXPRESS function

Usage example:

Query.Text = "CHOOSE | EXPRESS(Nomenclature.Comment AS String(300)) AS Comment, | EXPRESS(Nomenclature.Sum AS Number(15,2)) AS Sum |FROM | Reference.Nomenclature AS Nomenclature";

6. ISNULL function(alternative spelling IS NULL) - if the field is of type NULL, then it is replaced by the second parameter of the function.

Syntax: ISNULL(<Поле>, <ПодставляемоеЗначение>)

Usage example:

Also note that it is advisable to ALWAYS replace the NULL type with some value, because comparison with type NULL always returns FALSE even if you compare NULL with NULL. Most often, NULL values ​​are formed as a result of joining tables (all types of joins except internal ones).

Query.Text = //Select the entire item and its balances //if there is no balance in some item, then there will be a field //NULL which will be replaced with the value 0 "SELECT | No. Link, | ISNULL(ProductsInStockRemains.InStockRemaining, 0) AS Remainder | FROM | Directory.Nomenclature AS No. | LEFT CONNECTION Register Accumulations. GoodsInWarehouses. Remainings AS GoodsInWarehousesRemains | ON (GoodsInWarehousesRemains. Nomenclature = No. Link)";

7. REPRESENTATION function- allows you to get a representation of the request field.

Syntax: PERFORMANCE(<НаименованиеПоля>)

Usage example:

Query.Text = "SELECT | REPRESENTATION(FreeRemainingRemains.Nomenclature) AS Nomenclature, | REPRESENTATION(FreeRemainingRemaining.Warehouse) AS Warehouse, | FreeRemainingRemaining.InStockRemaining |FROM |Accumulation Register.FreeRemaining.Remaining AS FreeRemainingRemaining";

Constructs in the 1C query language

We discussed with you above 1C query language functions, now it's time to consider constructs in the 1C query language, they are no less important and useful, let’s get started.

1. Construction LINK- is a logical operator for checking a reference type. Most often encountered when checking a field of a complex type against a specific type. Syntax: LINK<Имя таблицы>

Usage example:

Request.Text = //if the recorder value type is document Receipt, //then the query will return "Receipt of goods", otherwise "Sales of goods" "SELECT | SELECT | WHEN Remainings.Registrar LINK Document.Receipt of Goods and Services | THEN ""Receipt"" | ELSE ""Consumption"" | END AS Type of Movement | FROM | Accumulation Register. Remaining Products in Warehouses AS Remains" ;

2. Design BETWEEN- this operator checks whether the value is within the specified range.

Syntax: BETWEEN<Выражение>AND<Выражение>

Usage example:

Request.Text = //get the entire nomenclature whose code is in the range from 1 to 100 "SELECT | Nomenclature.Link |FROM | Directory.Nomenclature AS Nomenclature |WHERE | Nomenclature.Code BETWEEN 1 AND 100" ;

3. Construction B and B HIERARCHY- check whether the value is in the transferred list (arrays, tables of values, etc. can be transferred as a list). The IN HIERARCHY operator allows you to view the hierarchy (an example of using the Chart of Accounts).

Syntax: IN(<СписокЗначений>), IN HIERARCHY(<СписокЗначений>)

Usage example:

Request.Text = //select all subaccounts of the account "SELECT | Self-supporting. Link AS Account | FROM | Chart of Accounts. Self-supporting AS Self-supporting | WHERE | Self-supporting. Link IN HIERARCHY VALUE (Chart of Accounts. Self-supporting. Goods)";

4. Design SIMILAR- This function allows us to compare a string with a string pattern.

Syntax: LIKE "<ТекстШаблона>"

Row pattern options:

% - a sequence containing any number of arbitrary characters.

One arbitrary character.

[...] - any single character, or a sequence of characters listed inside square brackets. The enumeration can contain ranges, such as a-z, meaning any character within the range, including the ends of the range.

[^...] - any single character, or a sequence of characters listed inside square brackets, except for those listed after the negation sign.

Usage example:

Query.Text = //find the entire nomenclature that contains the root TABUR and begins //either with a small or with a capital letter t "SELECT | Nomenclature.Reference |FROM | Directory.Nomenclature AS Nomenclature |WHERE | Goods.Name LIKE ""[Тт ]abur%""" ;

5. Design ALLOWED- this statement allows you to select only those records from the database for which the caller has the right to read. These rights are configured at the record level (RLS).

Syntax: ALLOWED is written after the keyword SELECT

Usage example:

Request.Text = "SELECT ALLOWED | Counterparties. Link | FROM | Directory. Counterparties AS Counterparties";

6. Design VARIOUS- allows you to select records in which there are no duplicate records.

Syntax: VARIOUS is written after the keyword SELECT

Usage example:

Request.Text = //selects records to which the reader has rights "SELECT VARIOUS | Counterparties.Name |FROM | Directory. Counterparties AS Counterparties" ;

Also, the VARIOUS construction can be used with the ALLOWED operator and other operators.

Usage example:

Request.Text = //selects various records to which the reader has rights "SELECT ALLOWED VARIOUS | Counterparties.Name |FROM | Directory. Counterparties AS Counterparties";

7. Design FIRST- selects the number of records specified in the parameter from the query result.

Syntax: FIRST<число>

Usage example:

Request.Text = //select the first 4 CCD numbers from the directory "SELECT FIRST 4 | CCD Numbers. Link | FROM | Directory. CCD Numbers AS CCD Numbers";

8. Design FOR CHANGE- allows you to lock a table, works only in transactions (relevant only for automatic locks).

Syntax: FOR CHANGE<НаименованиеТаблицы>

Usage example:

Query.Text = "SELECT | Free Remainings Remainings. Nomenclature, | Free Remainings Remainings. Warehouse, | Free Remainings Remainings. In Stock Remaining | FROM | Register of Accumulations. Free Remainings. Remainings AS Free Remainings Remainings | FOR CHANGE | Register of Accumulations. Free Remainings. Remainings";

9. Design ORDER BY- organizes data by a specific field. If the field is a link, then when setting the flag AUTO ORDER will be sorted according to the link representation, if the flag is off, then the links are sorted by the seniority of the link address in memory.

Syntax: SORT BY<НаименованиеПоля>AUTO ORDER

Usage example:

Query.Text = "SELECT | FreeRemainsRemains.Nomenclature AS Nomenclature, | FreeRemainsRemains.Warehouse AS Warehouse, | FreeRemainsRemains.In StockRemaining |FROM | Accumulation Register.FreeRemains.Remains AS FreeRemainsRemains | | ORDER BY | Nomenclature |AUTOORD RECOVERY";

10. Design GROUP BY- used to group query strings by specific fields. Numeric fields must be used with any aggregate function.

Syntax: GROUP BY<НаименованиеПоля1>, .... , <НаименованиеПоляN>

Usage example:

Query.Text = "SELECT | GoodsInWarehouses.Nomenclature AS Nomenclature, | GoodsInWarehouses.Warehouse, | SUM(ItemsInWarehouses.InStock) AS InStock |FROM | Accumulation register.GoodsInWarehouses AS GoodsInWarehouses | |GROUP BY | Warehouses.Warehouse";

11. Design HAVING- allows you to apply an aggregate function to a data selection condition, similar to the WHERE construction.

Syntax: HAVING<агрегатная функция с условием>

Usage example:

Query.Text = //selects grouped records where the InStock field is greater than 3 "SELECT | ItemsInStocks.Nomenclature AS Nomenclature, | ItemsInWarehouses.Warehouse, | SUM(ItemsInStocks.InStock) AS INSTOCK |FROM | RegisterAccumulations.ItemsInStocks AS ItemsInStocks | |GROUP BY | ProductsInWarehouses.Nomenclature, | ProductsInWarehouses.Warehouse | |AVAILABLE | AMOUNT(ProductsInWarehouses.InStock) > 3" ;

12. Construction INDEX BY- used for indexing the query field. A query with indexing takes longer to complete, but speeds up searching through indexed fields. Can only be used in virtual tables.

Syntax: INDEX BY<Поле1, ... , ПолеN>

Usage example:

Query.Text = "SELECT | Ts.NameOS, | Ts.FolderNumber, | Ts.CodeOS, | Ts.Term, | Ts.Type | PLACE DataTs | FROM | &Ts AS Ts | | INDEX BY | Ts.NameOS, | Ts .CodeOS";

13. Design WHERE- allows you to impose a condition on any selection fields. The result will include only records that satisfy the condition.

Syntax: WHERE<Условие1 ОператорЛогСоединения УсловиеN>

Usage example:

Query.Text = //all records with CompensationRemaining are selected<>0 and //AmountForCalcCompRemaining > 100 "SELECT | CompensationRPORemains.Counterparty, |CompensationRPORemains.Child, | CompensationRPORemains.CompensationRemaining, | CompensationRPORemains.AmountForCalcCompRemains |Place DataTz |FROM | Accumulation Register.CompensationRP.Remains AS CompensationRPOstat ki |WHERE |CompensationRPORemaining.CompensationRemaining<>0 | And CompensationRPORemains.AmountForCalcCompRemaining> 100" ;

14. Design RESULTS... GENERAL- used to calculate totals; the design specifies the fields by which totals will be calculated and aggregate functions applied to the total fields. When using totals for each field following the TOTAL construction, data is grouped. There is an optional GENERAL construct; its use also provides additional grouping. You will see an example of the request result below.

Syntax: RESULTS<АгрегатнаяФункция1, ... , АгрегатнаяФункцияN>BY<ОБЩИЕ> <Поле1, ... , ПолеN>

Usage example:

Request.Text = "SELECT | Calculations. Counterparty Agreement. Type of Agreement AS Contract Type, | Calculations. Counterparty Agreement AS Contract, | Calculations. Counterparty, | Calculations. Amount of Mutual Settlement Balance AS Balance | FROM | Register of Accumulations. Mutual Settlement WITH Counterparties. Balances AS Calculations | TOTAL | AMOUNT (Balance) |Software | GENERAL, | Type of Agreement";

The figure outlines the groupings that were formed during the execution of the request, the top one refers to the GENERAL section, and the second to the Counterparty AgreementAgreement Type field.

Request . Text = "CHOOSE | StorageUnits.Link |FROM | Directory.usStorageUnits HOW touseStorageUnits // Example 1: comparison with an empty boolean value: |WHERE | StorageUnits.AllowSelectionFromReserveZone = False // Example 2. but if this Boolean is defined, then it’s better like this: // condition for a negative Boolean: |WHERE | NOT Storage Units. Allow Selection From Reserve Zone // Example 3. selection based on the condition of an empty field that has the type “directory of a specific type” |WHERE | StorageUnits.ActiveSelectionArea = VALUE(Directory.usSelectionArea.EmptyRef) // Example 3a. selection based on the condition of an empty field having the type “document of a specific type” |WHERE | OurInformationRegister.Document = VALUE(Document.OurDocument.EmptyLink) // Example 3b. selection based on the condition of an empty field having the type “documents of different types” ( composite field) |WHERE | (OurInformationRegister.Document = VALUE(Document.OurDocument1.EmptyLink) | OR OurInformationRegister.Document = VALUE(Document.OurDocument2.EmptyLink) | OR... (etc. - we sequentially list the conditions for all possible types of this composite field) ) // Example 4. or vice versa, if you need to select a filled value of the "string" type, then the condition will help: |WHERE | Storage Unit.Name > """" // Example 5. if you need to select documents of a specific type, with a composite data type, for example, in the "RunningTasks" register, the "Task" resource has a composite type, among the values ​​of which the document "Selection" is possible |WHERE | EXPRESS(Information RegisterExecutedTasks.Task AS Document.Selection) LINK Document.Selection // Example 5a. Another similar example when you need to select documents of a specific type | CHOICE | WHEN TO EXPRESS (ag Correspondence of Documents. DocumentBU AS Document. Receipt of Goods and Services) LINK Document. Receipt of Goods and Services | THEN ""Receipt of Goods and Services"" | WHEN TO EXPRESS (ag Correspondence of Documents. DocumentBU AS Document. Sales of Goods and Services) LINK Document. Sales of Goods and Services | THEN ""Sales of Goods and Services"" | ELSE """" | END AS Document View // Example 6. selection by condition of an undefined value: |WHERE | SavedSettings.User = UNDEFINED // Example 7. selection by type of movement "Incoming" of the accumulation register, "Expense" - similarly): |WHERE | RegProductsInRetail.MovementType = VALUE(MovementTypeAccumulation.Incoming) // Example 8. How to indicate in a request that there is no need to execute the request (for example, you need to programmatically, depending on some condition, return an empty request result - Request.Text = StrReplace(Request.Text, "WHERE Doc.Link = &DocumentLink" , "WHERE IS THE LIE");). To do this, just add the condition “Where is False”. By the way, regardless of the volume of data requested in the sample, such a request will be executed instantly. |WHERE IS THE LIE // Example 9. Checking that the query result contains data: If notRequest.Execute().Empty() Then // Example 10. selection based on an empty date: |WHERE | tbStrings.CancellationDate = DATETIME(1, 1, 1)

In this article we will analyze the possibilities of type conversion in the 1C query language, which are provided by the “Express” function.
Let's look at several options for using this function.
And the first option is rounding numbers.

To do this, you need to use the Express function in the following format:

Express(<Число>as Number(<ДлинаЧисла>,<Точность>))

Where:
Number— the field that needs to be rounded
LengthNumbers— maximum number length
Accuracy— number rounding accuracy

The parameters both length and precision must be positive integers.
See how this function works in the image below.

The second use case is string casting. Very often, configurations use strings of unlimited length, which imposes some restrictions. For example, we cannot compare strings of unlimited length.
In the query below, the FullName field is of type string of unlimited length, and this query will not work.

In order for it to work, it is necessary to convert a field of unlimited length into a string with a certain length; this is done using the Express function in the following format:

Express(<Строка>as String(<ДлинаСтроки>)

Where
Line Length– the maximum length to which the string will be reduced.
Let's rework the query: in the condition we will convert an unlimited string to a string with a certain length. Then there will be no errors.

Let's consider the last and, I would say, the most important option for its application: when working with fields of a composite type.
Below are two queries that use composite fields. The first one is wrong and the second one is correct.

Those. When you need to get a field of some complex type, always get the value of this field only after casting the type using the Express function. In this case, the documents and reference books will have the following format:

Express(<Документ>as Document.<ИмяТаблицы>)
Express(<Справочник>as a Directory.< ИмяТаблицы >)
.

Where
TableName— object name in .

Always use the express function when working with composite types, it greatly optimizes the query.

If you are still “swimming” in the constructions of the query language, and even the simplest queries cause difficulties for you, then I recommend you my course “Queries in 1C from beginner to pro.” Where these and many other issues are discussed in more detail.

What is special about this course:
The course is designed for those who are not familiar with the query language in 1C;
The educational material is well laid out and easy to learn;
Several dozen lessons;
Useful practical examples;
All lessons are presented in clear and simple language

For my readers, 25% discount coupon: hrW0rl9Nnx

I try to release various interesting free articles and video tutorials as often as possible. Therefore, I will be very glad if you support my project by transferring any amount:

You can transfer any amount directly:
Yandex.Money — 410012882996301
Web Money - R955262494655

Join my groups.

Top Related Articles