Conditional constructs are the foundation of any business logic in 1C: Enterprise. Discount for a wholesale customer, blocking of shipment with a negative balance, selection of the VAT rate depending on the nomenclature group — all these tasks are solved through code branching. In this article, we will analyze the syntax of conditions, typical patterns, and real business scenarios that every 1C developer encounters.

Basic syntax: If … Then … EndIf
The simplest conditional construct in the 1C language consists of three mandatory elements: the keyword Если, followed by a logical expression, then the word Тогда, a code block, and the closing КонецЕсли. If the condition is true, the block inside the structure is executed. If false, it is skipped entirely.
// Simple check: prohibition of transactions with a zero amount
Если Объект.СуммаДокумента = 0 Тогда
Сообщить("The document amount cannot be zero!");
Отказ = Истина;
КонецЕсли;Please note: 1C does not have curly braces like JavaScript or C#. Block boundaries are defined by keywords. A semicolon is placed after КонецЕсли and after each operator inside the block.
The "Otherwise" branch — processing an alternative scenario
When you need to execute one block of code when the condition is true and another when it is false, use the construction with Иначе. This is a classic "or-or" pattern that is found in the vast majority of business tasks.
// Determine the price type for the customer
Если Контрагент.ОптовыйПокупатель Тогда
ТипЦены = Справочники.ТипыЦен.НайтиПоНаименованию("Wholesale");
Иначе
ТипЦены = Справочники.ТипыЦен.НайтиПоНаименованию("Retail");
КонецЕсли;Here the program checks the counterparty's details and, depending on its value, assigns one of two price types to the variable. The Иначе block is executed only when the condition after Если returned Ложь.
Multiple conditions: OtherwiseIf
Real business logic is rarely reduced to two options. When you need to check three or more scenarios, use the ИначеЕсли construction. The platform checks the conditions sequentially from top to bottom and executes the first block, the condition of which turned out to be true. All other branches are skipped.
// Discount calculation depending on the order amount
Если СуммаЗаказа >= 500000 Тогда
ПроцентСкидки = 15;
ИначеЕсли СуммаЗаказа >= 100000 Тогда
ПроцентСкидки = 10;
ИначеЕсли СуммаЗаказа >= 50000 Тогда
ПроцентСкидки = 5;
Иначе
ПроцентСкидки = 0;
КонецЕсли;The order of the branches in ИначеЕсли is critically important. If you put the check for 50,000 first, then the order for 500,000 will also fall into this branch, because 500,000 >= 50,000. Always arrange the conditions from the strictest to the mildest.
Logical operators: AND, OR, NOT
Conditions can be combined using three logical operators. This allows you to build complex checks that take into account several factors at the same time.
The И (conjunction) operator returns Истина when both conditions are true. The ИЛИ (disjunction) operator returns Истина when at least one condition is true. The НЕ (negation) operator inverts the value — returns Истина when the condition is false.
// Shipment is allowed if the goods are in stock and the customer is not blocked
Если ОстатокНаСкладе > 0 И НЕ Контрагент.Заблокирован Тогда
РазрешитьОтгрузку();
КонецЕсли;
// Special conditions for VIP clients or employees
Если Контрагент.VIP ИЛИ Контрагент.Сотрудник Тогда
ПрименитьСпециальнуюСкидку();
КонецЕсли;In 1C there is no "lazy" calculation of logical expressions (short-circuit evaluation). The platform always calculates both operands, even if the result is already obvious from the first one. This means that if the second operand can cause an error, you need to take it out in a separate check through the nested Если.
Comparison operators
A standard set of comparison operators is available for constructing conditions in 1C. They work with numbers, strings, dates and reference types: = (equal), <> (not equal), > (greater), < (less), >= (greater than or equal), <= (less than or equal).
// Examples of using comparison operators
Если Статус = "Paid" Тогда
// processing of a paid order
КонецЕсли;
Если Остаток <> 0 Тогда
// non-zero balance
КонецЕсли;
Если ДатаОтгрузки < ТекущаяДата() Тогда
// shipment date expired
КонецЕсли;
Если Количество >= МинимальнаяПартия Тогда
// quantity sufficient for shipment
КонецЕсли;Nested conditions
Inside any Если block, you can place other conditional constructs. This is called nesting. It allows you to implement step-by-step logic, where each next level of verification depends on the result of the previous one.
// Multi-level verification during document processing
Если Объект.Контрагент.Пустая() Тогда
Сообщить("No counterparty specified!");
Отказ = Истина;
Иначе
Если Объект.Контрагент.Заблокирован Тогда
Сообщить("Counterparty is blocked. Please contact your supervisor.");
Отказ = Истина;
Иначе
Если Объект.СуммаДокумента > Объект.Контрагент.КредитныйЛимит Тогда
Сообщить("Counterparty credit limit exceeded!");
Отказ = Истина;
КонецЕсли;
КонецЕсли;
КонецЕсли;Try not to go deeper than three levels of nesting. If the logic requires more, take the checks to separate functions or use the "early exit" by setting the variable Отказ and returning from the procedure.
Ternary operator: construction ?(…, …, …)
1C has a compact alternative to the If-Else construct for simple cases where you need to choose one of two values. This is a ternary operator that is written using a question mark.
// Full form:
Если Контрагент.ОптовыйПокупатель Тогда
Приветствие = "Dear Partner,";
Иначе
Приветствие = "Dear Customer,";
КонецЕсли;
// Compact form through ternary operator:
Приветствие = ?(Контрагент.ОптовыйПокупатель, "Dear Partner,", "Dear Customer,");Syntax: ?(Условие, ЗначениеЕслиИстина, ЗначениеЕслиЛожь). The ternary operator is convenient for assigning values to variables, forming strings, and setting parameters. Do not use it for complex logic — it impairs readability.

Real business scenarios
Let's consider a few typical tasks that a 1C developer faces in their daily work.
Scenario 1: Control of residues during shipment
When posting the "Sales of goods" document, you need to make sure that there is enough goods in the warehouse. If the balance is not enough, block the posting and show a clear message.
Для Каждого СтрокаТЧ Из Объект.Товары Цикл
Остаток = ПолучитьОстатокНаСкладе(СтрокаТЧ.Номенклатура, Объект.Склад);
Если СтрокаТЧ.Количество > Остаток Тогда
Сообщить("Not enough goods: "
+ СтрокаТЧ.Номенклатура
+ ". In stock: " + Остаток
+ ", required: " + СтрокаТЧ.Количество);
Отказ = Истина;
КонецЕсли;
КонецЦикла;Scenario 2: Automatic calculation of the VAT rate
Depending on the nomenclature group of the goods, the required VAT rate is automatically substituted. This eliminates the need for the manager to make a manual selection and reduces the likelihood of error.
Если Номенклатура.НоменклатурнаяГруппа = Группы.ДетскиеТовары
ИЛИ Номенклатура.НоменклатурнаяГруппа = Группы.Продовольствие Тогда
СтавкаНДС = Перечисления.СтавкиНДС.НДС10;
ИначеЕсли Номенклатура.НоменклатурнаяГруппа = Группы.Экспорт Тогда
СтавкаНДС = Перечисления.СтавкиНДС.НДС0;
ИначеЕсли Номенклатура.НоменклатурнаяГруппа = Группы.МедицинскиеИзделия Тогда
СтавкаНДС = Перечисления.СтавкиНДС.БезНДС;
Иначе
СтавкаНДС = Перечисления.СтавкиНДС.НДС20;
КонецЕсли;Scenario 3: Delineation of rights in coordination
Documents above a certain amount require approval by the manager. Simple managers can only send for approval, and managers can approve directly.
ТекущийПользователь = ПараметрыСеанса.ТекущийПользователь;
ЭтоРуководитель = ТекущийПользователь.Роль = Перечисления.Роли.Руководитель;
Если Объект.СуммаДокумента > 1000000 Тогда
Если ЭтоРуководитель Тогда
Объект.Статус = Перечисления.СтатусыДокументов.Утверждён;
Сообщить("The document is approved.");
Иначе
Объект.Статус = Перечисления.СтатусыДокументов.НаСогласовании;
Сообщить("The document has been sent to the manager for approval.");
КонецЕсли;
Иначе
Объект.Статус = Перечисления.СтатусыДокументов.Утверждён;
КонецЕсли;Scenario 4: Monitoring payment deadlines
The system automatically checks overdue payments and generates warnings of varying degrees of criticality.
ДнейПросрочки = (ТекущаяДата() - Объект.ДатаОплаты) / 86400;
Если ДнейПросрочки <= 0 Тогда
Статус = "On time";
ИначеЕсли ДнейПросрочки <= 7 Тогда
Статус = "A small delay";
ОтправитьНапоминание(Объект.Контрагент);
ИначеЕсли ДнейПросрочки <= 30 Тогда
Статус = "Critical overdue";
ОтправитьПретензию(Объект.Контрагент);
ЗаблокироватьОтгрузки(Объект.Контрагент);
Иначе
Статус = "Submitted to lawyers";
СоздатьЗадачуЮристу(Объект.Контрагент, ДнейПросрочки);
КонецЕсли;Typical mistakes and how to avoid them
Error 1: Comparison with an empty link
Beginners often write Если Контрагент = "" Тогда, trying to check the completeness of the reference details. This is incorrect — the string and the link have different types. To check if a link is empty, use the Пустая() method or the ЗначениеЗаполнено() function.
// Incorrect:
Если Объект.Контрагент = "" Тогда
// Correct:
Если Объект.Контрагент.Пустая() Тогда
// Also correct (universal version):
Если НЕ ЗначениеЗаполнено(Объект.Контрагент) ТогдаMistake 2: Forgotten "Then"
Unlike most programming languages, in 1C the keyword Тогда must follow the condition. Without it, the platform will give a syntax error. This is one of the most common mistakes when switching from other languages.
Error 3: Wrong order in OtherwiseIf
As already mentioned, the order of conditions is critically important. The platform executes the first branch whose condition is true. If you arrange the conditions from soft to strict, more specific branches will never work.
Error 4: Excessive nesting
Deep nesting makes it difficult to read and debug the code. Use the "early exit" pattern: check for invalid conditions at the beginning of the procedure and exit immediately through Возврат.
// Deep nesting (bad):
Если УсловиеА Тогда
Если УсловиеБ Тогда
Если УсловиеВ Тогда
// main code
КонецЕсли;
КонецЕсли;
КонецЕсли;
// Early exit (good):
Если НЕ УсловиеА Тогда
Возврат;
КонецЕсли;
Если НЕ УсловиеБ Тогда
Возврат;
КонецЕсли;
Если НЕ УсловиеВ Тогда
Возврат;
КонецЕсли;
// main code — without nestingConditions in the 1C query language
In addition to the built-in language, conditional constructs are actively used in the 1C query language. Here the operator ВЫБОР is used, similar to CASE in SQL.
ВЫБОР
КОГДА Продажи.Сумма >= 500000
ТОГДА "Large order"
КОГДА Продажи.Сумма >= 100000
ТОГДА "Average order"
ИНАЧЕ "Small order"
КОНЕЦ КАК КатегорияЗаказаThe ВЫБОР operator can be used in the ВЫБРАТЬ, ГДЕ, УПОРЯДОЧИТЬ ПО sections and even in the table join conditions. This is a powerful tool for forming calculated fields and filtering data at the DBMS level.
Conclusion
Conditional statements are a tool that you will work with every day. Simple Если-Тогда turns into complex business rule trees that manage discounts, access rights, approval routes, and dozens of other processes. The main thing is to write the conditions clearly, arrange the branches in the correct order and not be afraid to take complex logic into separate functions. Clean code with conditions is code that your colleagues will be able to read and maintain months and years later.
If you are starting your journey in development or want to deepen your knowledge — the application Code will help you learn programming from scratch. Structured courses in Python, JavaScript, HTML, CSS, 1C and other technologies, practical tasks and clear explanations — all in one place. Download the Kodik app from the App Store and Google Play, and if you have any questions, join our Telegram channel with support, where more than 2000 developers are already discussing code, sharing experiences and helping each other. It's easier to learn together!
