Scope: managed applications, mobile applications.
1. To open forms, employ the OpenForm global context method. For 1C:Enterprise platform version 8.2 and earlier, you can also use the OpenFormModal method. It is not recommended to employ the GetForm method to get and open forms.
By following this best practice, you will:
- Increase the code robustness, since the application interface and the form's internal implementation are separated.
- Keep the code consistent with other 1C:Enterprise applications.
Also, OpenForm initializes the form on the server, with the OnCreateAtServer handler. Such approach ensures that all initialization code of the form is executed in the same place, which eliminates unwanted client-to-server calls from the code between
Form = GetForm(...)
Form.OpenForm(...) code strings.
See also: Opening managed forms in Minimizing the number of server calls.
Specify the parameters in the code that opens the form (OpenForm).
MyForm = Form.OpenForm("CommonForm.SystemGuide");
MyForm.Items.GroupStep.CurrentPage = MyForm.Items.GroupStep.Pages.Salutation;
OpenForm("CommonForm.SystemGuide", New Structure("OpeningMode", "Salutation"));
QuestionForm = GetForm("CommonForm.QuestionForm");
If QuestionForm.DoNotShowReminder Then
Instead, embed a notification handler that is called on form close. Correct:
Notification = New NotifyDescription("DoNotShowReminderEnd", ThisObject);
OpenForm("CommonForm.QuestionForm",,,,, Notification, FormWindowOpeningMode.LockWholeInterface);
Procedure DoNotShowReminderEnd(DoNotShowReminder, Parameters) Export
If DoNotShowReminder = Undefined Then
If DoNotShowReminder Then
In this case, the return value is generated in the code of the form's module with the Close method.
- Do not embed code that opens another form into the OnOpen event handler. This might lead to an unexpected form display order. Instead, embed a shot-time idle handler or let the user to open other forms interactively.
- It is not recommended to employ solutions where a single handler programmatically opens and closes the form. Form opening and form closing must be staggered. For example, embed code that closes the from into an idle handler.
- If you develop a form specifically for external users, ensure that this form will never open in the local user's sessions. To do so, in the Users or UsersClient common module, embed the Cancel parameter to code block that creates the form for external users (IsExternalUserSession):
Procedure OnCreateAtServer(Cancel, StandardProcessing)
If Not UsersClientServer.IsExternalUserSession() Then
Cancel = True;
Main list form
Main form of data processor
Main form of report