Object Event Handlers
MCP routing
- Preferred path: use MCP
unicatoolsunica.view {},unica.viewon the object node,unica.search,unica.apply,unica.check, andunica.run. - Runtime идёт через
unica.run: вызов безopотдаёт словарь операций и контракт каждой —argsSchema,execution,previewRequired,ifRevRequiredOnApply. Контракт вызова бери оттуда, а не из этого текста; выбирай только операцию сimplemented: trueи не выдумывай аргументов записи сargsSchema: null; превью исполнением не является. Не обходи контракт прямым runner-ом. - Use
unica.docswithsource: "development-standard"for the standards about handlers: 396, 455, 463, 464, 465, 466, 686, 752, 773, and diagnostics АПК:75, АПК:144, АПК:1340, BSLLS:DataExchangeLoading, BSLLS:UsingCancelParameter, BSLLS:MissingEventSubscriptionHandler. These are standards, not evidence of runtime behavior; confirm the wording before citing one. - Do not call internal analyzer, runtime, standards, or package adapters directly. They are hidden behind MCP
unica.
References
- Read
../../references/platform/object-events.mdfor the handler map, the conditional fill-check shape, the exchange guard, and the cancel-parameter rule. - Read
../../references/platform/document-posting.mdwhen the handler in question isОбработкаПроведенияorОбработкаУдаленияПроведения. - Read
../../references/platform/platform-mechanics.mdfor transaction boundaries and logging inside write handlers.
Core model
Pick the handler by what the logic needs to see, not by what is convenient:
- Needs the fill source →
ОбработкаЗаполнения. Refusing "create based on" belongs here too, raised as an exception, not moved into a separate command handler (std396). - Needs to reject bad data before writing →
ОбработкаПроверкиЗаполнения(std463). - Needs the old stored values, or must fill or check before the write →
ПередЗаписью(std464). - Needs the object to already exist in the database →
ПриЗаписи. Do not modify the object there; it is already written (std465). - Needs to run before the object disappears →
ПередУдалением(std752). - Needs to strip values that must not survive a copy →
ПриКопировании(std466).
Two rules cut across all of them: ОбменДанными.Загрузка is checked first in ПередЗаписью, ПриЗаписи, and ПередУдалением (std773), and Отказ is only ever assigned Истина (std686).
Workflow
- Name what the logic needs to observe — fill source, old values, written state, or nothing yet — and let that pick the handler.
- Locate what already runs: read the object module with
unica.viewon the module node (itsMethodbranch lists the methods), and find subscriptions on the same events withunica.searchandunica.viewon the object node. A subscription is invisible from the object module it affects. - Search the shared procedures the handler calls with
unica.searchto see what else the change reaches; a call graph is not on the v0.13 surface. - Write the guard before the logic:
Если ОбменДанными.Загрузка Тогда Возврат; КонецЕсли;— in the subscription handler too, not only in the object module. - Express conditional requiredness by collecting
НепроверяемыеРеквизитыand removing them fromПроверяемыеРеквизитыat the end, never by adding toПроверяемыеРеквизиты. - Apply the change with
unica.apply, one verifiable step at a time. - Verify statically with
unica.checkon the module node (test runs are outside the v0.13 surface), and require separate runtime evidence for the exchange path when the object participates in one.
Design rules
- The object must load as it is during exchange: no repeated business logic, no extra checks, no changes that could distort data or block the load (std773). Code that sets
ОбменДанными.Загрузка = Истинаtakes responsibility for the object's integrity itself. - Never assign
ЛожьtoОтказ, and never assign a boolean function result to it — either can clear aИстинаset earlier in the same handler or by another subscriber (std686, АПК:144). The rule coversСтандартнаяОбработкаandВыполнениеtoo. - Setting
Отказ = Истинаwithout a message leaves the user the platform's own text, which names the object and nothing else. Report the reason, or raise an exception instead. - Adding names to
ПроверяемыеРеквизитыhides the conditional check from analysis of theПроверка заполненияproperty (std463). - Event handlers belong in the standard event-handler region; procedures that are not handlers do not (std455, АПК:1340).
Review checklist
ПередЗаписью,ПриЗаписи, andПередУдалениемcheckОбменДанными.Загрузкаbefore anything else — in subscription handlers as well as object modules (АПК:75).- Any exception to that guard carries a comment stating the reason.
ПриЗаписиdoes not modify the object being written.- Conditional fill checks remove from
ПроверяемыеРеквизиты, never add to it. Отказis only ever assignedИстина, and every refusal tells the user why.- Every declared subscription has its handler procedure.
- Subscriptions on the same events were reviewed together with the object module change.
Stop rules
- Do not move a "create based on" refusal out of
ОбработкаЗаполненияinto command handlers. - Do not add logic to a write or delete handler without the exchange guard.
- Do not conclude what runs on write or delete from the object module alone before checking subscriptions.
Contract gaps
If public MCP unica cannot inspect the object's modules, its subscriptions, or the diagnostics needed for the task, report a Unica MCP contract gap with the missing operation.