Managed forms
Managed forms — attributes and items, form events, commands, asynchronous dialogs and conditional formatting.
8 questions
JuniorTheoryVery commonHow does a form attribute differ from a form item?
How does a form attribute differ from a form item?
A form attribute is data: a value the form keeps and passes between client and server, such as Объект or a table. A form item is what the user sees: a field, a table or a button, usually bound to an attribute through ПутьКДанным.
Common mistakes
- ✗Reading a value from
Элементы.Полеinstead of the attribute: the value lives in the attribute - ✗Expecting every form attribute to be saved to the database: only the object in
Объектis written when the object is saved
Follow-up questions
- →Why can a form keep an attribute that no item shows?
- →How do you hide a field from code without touching its data?
JuniorTheoryVery commonHow does ПриОткрытии differ from ПриСозданииНаСервере in a form?
How does ПриОткрытии differ from ПриСозданииНаСервере in a form?
ПриСозданииНаСервере runs first, on the server, while the form is built: read data, fill attributes, set up items, refuse to open with Отказ. ПриОткрытии runs next, on the client, just before the form appears, for client-only work.
Common mistakes
- ✗Querying the database in
ПриОткрытии: it runs on the client, so data belong inПриСозданииНаСервере - ✗Calling the server from
ПриОткрытииfor data the form could fill at creation: an extra server call on every opening
Follow-up questions
- →Which form event runs before
ПриСозданииНаСервереwhen an existing object's form opens? - →How does a form learn in
ПриСозданииНаСервереthat the object is new?
MiddleTheoryVery commonHow do you ask the user a question in a managed form?
How do you ask the user a question in a managed form?
Call ПоказатьВопрос with an ОписаниеОповещения naming an export handler: code goes on at once, and the handler gets the answer later. An Асинх procedure may use Ждать ВопросАсинх(...). Modal Вопрос() is off in new configurations.
Common mistakes
- ✗Reading the answer on the line after
ПоказатьВопрос: the code has gone on, and the answer arrives in the handler - ✗Leaving the notification handler without
Экспорт: the platform cannot call it
Follow-up questions
- →What does the notification handler receive as its second parameter?
- →Why does the code after
ПоказатьВопросrun before the user answers?
JuniorTheoryCommonWhat does the form of an existing item print when it opens (lines separated by spaces)?
What does the form of an existing item print when it opens (lines separated by spaces)?
чтение создание открытие
Open full question →Common mistakes
- ✗Expecting
ПриСозданииНаСервереbeforeПриЧтенииНаСервере: an existing object is read first - ✗Expecting
ПриОткрытииto come before the server events: it is a client event and runs last of the three
Follow-up questions
- →Which of these events run when the form of a new item opens?
- →Why is the form data prepared in
ПриСозданииНаСервереrather than inПриОткрытии?
JuniorTheoryCommonIn what order do the messages appear if the user answers «Да»?
In what order do the messages appear if the user answers «Да»?
A B
Open full question →Common mistakes
- ✗Expecting the code after
ПоказатьВопросto wait for the answer: it runs at once, and the answer arrives in the notification handler - ✗Writing an action that depends on the answer after
ПоказатьВопрос: it belongs in the procedure named inОписаниеОповещения
Follow-up questions
- →How do you rewrite this code with
АсинхandЖдать? - →Why does the modal
Вопрос()not work in new configurations?
MiddleTheoryCommonWhat is conditional formatting in a managed form, and why use it?
What is conditional formatting in a managed form, and why use it?
Conditional formatting is a list of rules in the form's УсловноеОформление: a condition on data, the fields it applies to and an appearance, such as red text for an overdue row. The platform applies it to each row itself, with no code per row.
Common mistakes
- ✗Colouring rows in a client loop: conditional formatting does it on the platform side without code
- ✗Expecting conditional formatting to change the data: it changes only the appearance
Follow-up questions
- →How do you add a conditional formatting rule from code in
ПриСозданииНаСервере? - →Which appearance properties can a conditional formatting rule set?
MiddleTheoryCommonWhy do new 1C configurations not use modal windows?
Why do new 1C configurations not use modal windows?
Since 8.3.3 a new configuration has «Режим использования модальности» set to «Не использовать», so Вопрос() and other modal calls fail in every client. The reason is the web client: browsers block modal pop-ups, and mobile ones cannot show them.
Common mistakes
- ✗Calling
Вопрос()in a new configuration: modality is off and the call fails - ✗Treating modality as a setting of one form: it is a property of the whole configuration
Follow-up questions
- →What does the value «Использовать с предупреждением» do?
- →How would you rewrite a procedure that called
Вопрос()in the middle of a loop?