- Choose the right metadata object for a task
- Recognise the standard attributes and tabular sections of catalogs and documents
- Create a catalog item and a document in code and tell a reference from an object
In ordinary programming you create database tables, forms and menus by hand. In 1C you simply describe a metadata object — for example “Products catalog, attributes: Price, Unit” — and the platform builds the table, the list and item forms and the commands by itself. A configuration is assembled from such ready-made building blocks.
Constants and catalogs
A constant (Константа) stores a single value for the whole base: the company name, the main currency, whether VAT is used. A catalog (Справочник) is a list of items of the same kind: products, counterparties, employees, warehouses. Every catalog has standard attributes: Код (Code), Наименование (Description), ПометкаУдаления (DeletionMark) and Ссылка (Ref).
- Hierarchy: a catalog can be split into groups (
Иерархия групп и элементов), which adds theРодитель(Parent) andЭтоГруппа(IsFolder) attributes. For example “Drinks → Tea”. - Owner (
Владелец): one catalog can be subordinate to another, for example contracts belong to a counterparty. - Attributes and tabular sections: your own fields (Price, Unit) and lists of rows (for example a product's barcodes).
- Predefined items are created in the Configurator and referred to by name in code:
Справочники.Склады.Основной.
A reference (Ссылка) is a lightweight “address” of a record in the base: it is stored in attributes and compared, but you cannot change data through it. An object (СправочникОбъект) is a full copy of the record loaded into memory: you change it and save it with Записать() (Write).
// Новый элемент справочника
НовыйТовар = Справочники.Товары.СоздатьЭлемент();
НовыйТовар.Наименование = "Çay 100 q";
НовыйТовар.Цена = 3.5;
НовыйТовар.Записать();
// Поиск и изменение существующего элемента
ТоварСсылка = Справочники.Товары.НайтиПоНаименованию("Çay 100 q");
Если Не ТоварСсылка.Пустая() Тогда
ТоварОбъект = ТоварСсылка.ПолучитьОбъект();
ТоварОбъект.Цена = 4;
ТоварОбъект.Записать();
КонецЕсли;
// Константа
Валюта = Константы.ОсновнаяВалюта.Получить();Справочники.Товары) → object → Записать(). In English syntax: Catalogs, CreateItem(), FindByDescription(), GetObject(), Write().Documents
A document (Документ) records a business transaction that happens at a point in time: goods received, a sale, a payment. Its standard attributes are Номер (Number), Дата (Date), Проведен (Posted) and ПометкаУдаления. Numbers are assigned automatically and can, for example, restart every year. The document's key ability is posting (проведение): a posted document creates records in registers — we will study this in a separate lesson.
- 1Add a document
Документы→Добавить, name:ПриходТовара(goods receipt). The synonym becomesПриход товараautomatically. Tick theСкладsubsystem. - 2Create a tabular section
On the
Данныеtab:Табличные части→Товары, columns:Товар(typeСправочникСсылка.Товары),Количество,Цена,Сумма(Число). - 3Check it
Press F5, create a new document in the
Складsection and add a few rows to the tabular section. The platform built the form automatically — you did not draw any form.
Приход = Документы.ПриходТовара.СоздатьДокумент();
Приход.Дата = ТекущаяДатаСеанса();
НоваяСтрока = Приход.Товары.Добавить();
НоваяСтрока.Товар = Справочники.Товары.НайтиПоНаименованию("Çay 100 q");
НоваяСтрока.Количество = 10;
НоваяСтрока.Цена = 4;
НоваяСтрока.Сумма = НоваяСтрока.Количество * НоваяСтрока.Цена;
Приход.Записать(); // номер присвоится автоматическиСервер flag).Enumerations and other objects
An enumeration (Перечисление, Enum) is a fixed list whose values only the developer defines: payment types (cash, card), order statuses. In code: Перечисления.ВидыОплаты.Наличные. Users cannot add new values — that is the key difference from a catalog.
| Object | Purpose | Example |
|---|---|---|
Регистры сведений / накопления | accumulated or time-dependent data | stock balances, prices |
Отчеты | analysing and printing data | a sales report |
Обработки | service operations | bulk price change |
Общие модули | reusable code | tax calculation functions |
Роли | access rights | a “Storekeeper” sees only warehouse documents |
Подсистемы | interface sections | Warehouse, Sales, Accounting |
Key points
- You describe a metadata object — the platform creates the table, forms and commands itself.
- Catalogs are for lists (
Код,Наименование, hierarchy); documents are for time-stamped transactions (Номер,Дата, posting). - A reference is read-only; to change data you need
ПолучитьОбъект()andЗаписать(). - Only the developer defines the values of an enumeration.
- Names are written in CamelCase without spaces; users see the synonym.
Check yourself
10 questions. Every correct answer earns XP.