Warning without modality mode. Why does the error “The use of modal windows in this mode is prohibited” occur? Instructions for correcting the error for ordinary users

The article will discuss the main reasons for abandoning modality in the 1C:Enterprise platform and the main methods for converting code sections to a new asynchronous model.

Applicability

The article discusses the asynchronous model for constructing business logic, the added platform “1C:Enterprise” edition 8.3. The information presented is relevant for current platform releases.

Refusal to use modal windows in the 1C:Enterprise 8.3 platform

When developing a configuration on the 1C:Enterprise 8 platform, the need periodically arises to pause the program until the user makes a decision or performs some action.

For example, when clicking on the fill tabular section button, the user should be asked whether the tabular section needs to be cleared so that previously entered data is not lost.

This behavior can be achieved, for example, by the following code:

&OnClient
Procedure Fill in Products(Team )
Answer = Question (“The table part will be cleared. Continue?”, Dialogue ModeQuestion.YesNo);
If Answer = Dialogue Return Code.Yes Then
//filling algorithm
EndIf ;
End of Procedure

As a result of this code fragment, the execution of the program code will be suspended, a question will be displayed on the screen, the application interface except for the dialog with the question will become unavailable, the system waits for the user to make a decision, and code execution will continue only after the question is answered.

Opening modal windows by calling the OpenModal() method also causes pauses in code execution and blocking of the interface.

When working with the configuration in web client mode through a browser, in this case a new window will open - a pop-up window that will block not only the current tab, but also the entire browser interface, including other open windows and tabs.

Pop-up windows on the Internet are often used to maliciously distribute unwanted advertisements, which is why browsers contain pop-up blocking features.

In this case, to work with 1C:Enterprise 8 configurations through a browser, you must disable pop-up blocking.

Problems also arise when working on mobile devices. For example, modal windows are not supported on iPad.

To solve these problems, you should use blocking windows instead of modal ones. For the user, visually everything looks the same: the window blocks the web client interface.

However, the blocking window is “drawn” on top of the main window, and only the current browser tab in which the configuration is open is blocked, allowing you to switch to other tabs, since modal browser windows are not used.

Thus, pop-up windows do not open in the browser and work through the web client on mobile devices is ensured.

The root element of the configuration has a property “Modality mode”, which determines whether modal windows can be opened in the configuration.

If the “Use” option is selected, then modal windows can be opened. If the “Do not use” option is selected, then modal windows are not allowed. When you try to call a method that opens a modal window, the system displays an error message:

With this value of the “Modality usage mode” property, only blocking windows are allowed.

If the “Use with warnings” option is selected, then when modal windows are opened, the following text is displayed in the message window:

This work option can be used as an intermediate one when reworking the configuration in order to abandon the use of modal windows.

The main difference between blocking windows and modal windows is that opening a blocking window does not pause code execution.

Therefore, developers will have to rewrite the program code that uses modal windows to take this feature into account.

The code needs to be divided into two parts:

  • opening a blocking window;
  • processing user selection.

The code fragment given at the beginning of the article needs to be rewritten as follows:

&OnClient
Procedure Fill in Products(Team )
Alert = New DescriptionAlerts(, ThisObject );

Dialogue ModeQuestion.YesNo);
End of Procedure
&OnClient
Procedure (Result, Extra options) Export
If Result = Dialogue Return Code.Yes Then
//filling algorithm
EndIf ;
End of Procedure

After executing the ShowQuestion() procedure, the system does not stop, waiting for the user's response, code execution continues.

The user will be able to make a choice only after the entire procedure is completed. In this case, the export procedure FillItemsQuestionComplete() will be called. We passed its name to the constructor of the DescriptionAlerts object.

The procedure that will be called after making a selection can be located in a form module, a command module, or a general non-global module.

In the example considered, the called procedure is located in a managed form module, so we passed in the ThisObject parameter.

Let's consider calling a procedure located in a common module. To do this, add a new common module Notification Processing, set the “Client (managed application)” flag for it, and do not set the “Global” flag. Let's place the procedure Fill in Products Question Completion () in this module.

Then the fill command handler will look like this:

&OnClient
Procedure Fill in Products(Team )
Alert = New DescriptionAlerts(“Fill in Products Question Completion”,
ProcessingAlerts);
Question Text = “The tabular part will be cleared. Continue?" ;
ShowQuestion (Alert , Question Text , Dialogue ModeQuestion.YesNo);
End of Procedure

After calling any method that opens a blocking window, the procedure must exit, and the code that runs next should be placed in a procedure that will be called after the window is closed.

To transfer context (auxiliary data, certain parameters, variable values) from the procedure that opens the modal window to the procedure called when it is closed, a third optional parameter of the object constructor is provided: DescriptionAlerts – Additional Parameters.

This object (of any type) will be passed to the procedure described in Alert Description as the last parameter.

Using the example of the code section discussed above, this can be done like this:

&OnClient
Procedure Fill in Products(Team )
Parameter1 = 0 ;
Parameter2 = 0 ;
List of Parameters= New Structure (“Parameter1, Parameter2″, Parameter1, Parameter2);
Alert = New DescriptionAlerts(“Fill in Products Question Completion”, ThisObject ,
List of Parameters);
ShowQuestion (Alert, “The table part will be cleared. Continue?”,
Dialogue ModeQuestion.YesNo);
End of Procedure
&OnClient
Procedure Fill inProductsQuestionCompletion(Result , Extra options) Export
If Result = Dialogue Return Code.Yes Then
//analyze Additional Parameters.Parameter1
//analyze Additional Parameters.Parameter2
EndIf ;
End of Procedure

If you need to pass only one value, then you can not use the structure, but assign this value to the Additional Parameters parameter of the constructor of the DescriptionAlerts object.

Let's look at a few examples of working with blocking windows.

Task 1: Open another form

From the document form, by clicking on the “Open parameters” button, you need to open a form on which there are two checkboxes Parameter1 and Parameter2, which the user must set. After closing the form, display the parameter values ​​in the message line.

We create a general form “ParametersForm”, on which we place the details Parameter1 and Parameter2, as well as the CloseForm command:

The command handler looks like this:

The command handler looks like this: &OnClient
Procedure CloseForm (Command)
List of Parameters= New Structure ( “Parameter1, Parameter2”, Parameter1 , Parameter2 );
Close ( List of Parameters); End of Procedure

For the form, set the WindowOpenMode property to “Block entire interface”:

On the document form we place the OpenParameters command, the handler of which is described as follows:

&OnClient
Procedure OpenOptions(Team )
Alert = New DescriptionAlerts(“Open Options Finish”, ThisObject );
OpenForm ( “GeneralForm.FormParameters”, , , , , , Notification);
End of Procedure
&OnClient
Procedure OpenOptionsComplete(Result , Extra options) Export
If TypeValue (Result) = Type (“Structure”) Then
For each KeyValue From Result Loop
Message = New Message to User;
Message.Text = “Key: “” ” + KeyValue.Key + “””, value = ”
+ KeyValue.Value;
Message.Report();
EndCycle ;
EndIf ;
End of Procedure

In user mode, running the configuration under the web client, we get the following results:

To enlarge, click on the image.

The window opening mode can also be specified in the last parameter of the OpenForm procedure.

&OnClient
Procedure OpenOptions(Team )
Alert = New DescriptionAlerts(“Open Options Finish”, ThisObject );
OpenForm ( “GeneralForm.FormParameters”, , , , , , Alert
FormWindowOpenMode.LockEntireInterface
);
End of Procedure

Task 2. Question when closing the form

When closing a processing window, ask the user whether he really wants to close the window.

This problem can be solved using the following code located in the processing form module:

&OnClient
Perem Need to Close the Form;
&OnClient
Procedure Before Closing (Failure, StandardProcessing)
If not Need to Close the Form= True Then
Refuse = True ;
Alert = New DescriptionAlerts(“Before ClosingCompletion”, ThisObject );
ShowQuestion (Alert, “Are you sure you want to close the window?”,
Dialogue ModeQuestion.YesNo
);
EndIf ;
End of Procedure
&OnClient
Procedure Before Closing Completion(Result , Extra options) Export
If Result = Dialogue Return Code.Yes Then
Need to Close the Form= True ;
close();
Otherwise
Need to Close the Form= Undefined ;
EndIf ;
End of Procedure

In the BeforeClosing form procedure, the user is asked a question, the Refusal flag is set to True, and the closing of the form is cancelled.

After an affirmative answer to the question, the variable Need toCloseForm is set to True, and the form is closed again.

Task 3: Entering a Numeric Value

When you click on the button on the processing form, open a standard number entry dialog.

To do this, you need to use the ShowNumberInput() method instead of EnterNumber(), which opens a blocking window instead of a modal one.

&OnClient
Procedure Entering Numbers (Command)
Alert = New DescriptionAlerts(“EnterNumberComplete”, ThisObject );
ShowEnterNumbers(Alert, 0, “Enter quantity”, 15, 3);
End of Procedure
&OnClient
Procedure EnteringNumbersCompleting(Result , Extra options) Export

Message = New Message to User;
Message.Text = “You have entered a quantity” + Result;
Message.Report();
EndIf ;
End of Procedure

After closing the number entry window, a procedure will be called, the first parameter of which will be the entered number or the Undefined value if the user refused to enter.

Task 4. Choosing a color

When you click on the button on the processing form, using the standard color selection dialog, the user specifies the required color. Set this color for the background of the clicked button.

Add the SelectColor command to the form with the following handler:

&OnClient
Procedure Color Selection (Command)
Color Selection Dialog= New Color Selection Dialog;
Alert = New DescriptionAlerts(“Color SelectionComplete”, ThisObject );
Color Selection Dialog. Show(Alert);
End of Procedure
&OnClient
Procedure ChoiceColorsCompletion(Result , Extra options) Export
If NOT Result = Undefined Then
Elements.Color Selection.Background Color= Result ;
EndIf ;
End of Procedure

For Color Selection Dialog objects (as well as Standard Period Editing Dialog, Format Line Constructor, Regular Task Schedule Dialog, Font Selection Dialog), the Show() method opens a blocking window.

After closing the window, a procedure will be called, the first parameter of which will be passed the selected value (color, font, etc.) or the Undefined value if the user has refused the choice.

It should be noted that the FileSelectionDialog object does not have a Show() method, unlike color or font selection dialogs, since the implementation of these dialogs is significantly different.

To use the file selection dialog on the web client, you must first enable the file extension.

Dialogs implemented through the file extension do not create the same operational problems as modal browser windows, so opening blocking windows for the FileSelectionDialog object was not implemented.

In conclusion, we note that starting with release 8.3.10, support for modal windows has been discontinued in the web client. In this case, if a modal method is called in the configuration, an exception is generated. Also, support for interface mode has been discontinued in the web client In separate windows. In addition, in both the thin and web clients it is no longer possible to open a form in a separate window (when working in the Bookmarks interface mode). Such drastic steps made it possible to abandon the interface mode, which is no longer supported by all modern browsers.

What practical conclusion can be drawn from this information? And the conclusion is quite simple - if for some reason there are still modal calls in your configuration, then in these places in the web client a window with an error message will be displayed. I would like to warn against trying to “Google” some quick solution to this problem, because... Most of the advice comes down to this recipe: in the configurator at the configuration level, set the “Modality use mode” property to “Use”. Naturally, at the moment, this will not work only because modern browsers no longer support modal calls.

And you have only two ways to solve the problem described above:

  1. Update the platform to release 8.3.10+ (8.3.11), set the “Compatibility Mode” configuration property to “Do not use” and rewrite code fragments that use modal methods to an asynchronous business logic model
  2. Encourage your customers to use legacy browsers that still supported modal calls ( Mozilla Firefox versions 37 and below, Chrome versions below 37, etc.).

By the way, starting with release 8.3.11, Microsoft web browsers are no longer supported Internet Explorer versions 8 and 9.

We have dealt with web browsers in the light of modality, now it’s time to clarify the situation with other clients.

Starting with version 8.3.5, the Modality Usage Mode property in thin and thick clients is respected only if the /EnableCheckModal command line option is specified. This parameter is automatically substituted in command line only when launching the application from the configurator. If this parameter is not specified, then no exceptions are generated and corresponding warnings are not shown. Those. in practice, when using a thick and thin client, no fundamental change in operation is observed when using the modal mode - modal calls will work the same as they worked before, without producing any warnings, as in the web client.

To dot all the “i”s, we note that starting from edition 8.3.9, the configuration property “Mode of using synchronous calls of platform extensions and external components” is ignored in the thick client, while the corresponding synchronous methods work without generating exceptions and displaying warnings. The specified ignored property was added in version 8.3.5 to support asynchronous work with external components, cryptography and extensions for working with files in a web browser Google Chrome. It is clear that this has nothing to do with the thick client, and therefore “quietly” ignoring this property simply eliminated unnecessary checks for the use of synchronous methods when using the configuration.

By the way! Due to the fact that the platform is confidently moving towards the web, with version 8.3.8 the developers have introduced certain restrictions on the program code that is associated with the logic for closing a form or application, executed in thick and thin clients. Be sure to read our article covering this nuance in detail. In addition, in the course “Professional development of interfaces and forms in 1C: Enterprise 8.3”, there is a chapter dedicated to the abandonment of modality, and you can glean a lot of useful and relevant information on this topic.

Colleagues, there are two things that you can read endlessly: the VKontakte feed and the list of changes in the next release of the platform, so let’s sum up the final results;)

In the process of considering examples that allow you to move from elements of a synchronous model to an asynchronous one, you probably already noticed that in the general case there is more program code. The more code there is, the more the complexity of its further maintenance and debugging increases.

In addition, the amount of code will increase even more if we use more dialogs during the development process. Therefore, in the process of developing application solutions focused on working in a web client, you need to remember the work paradigm that is currently used in modern web applications. Therefore, if your configuration contains a lot of interactive dialogs with the user and warnings, then it makes sense to reconsider this functionality in favor of some other approaches to organizing user interaction.

Instead of a conclusion

Our cycle “First steps in 1C development” has come to an end. If you read it in its entirety, then most likely you have already noticed how the platform has been developing by leaps and bounds lately. The material in this series was written relatively recently, but we were forced to seriously update it, because... even in such a short period of time, a lot of new important functionality and changes. Such major changes can be somewhat perplexing for a 1C programmer if he has not grown and developed professionally with the platform all this time.

On specialized Internet resources you can often read requests from novice programmers and their more mature colleagues to recommend materials that would help them understand the extensive and sometimes seemingly endless capabilities of the 1C platform. We, traditionally, recommend that you pay attention to our programming courses

14
To force an enterprise launch in an Ordinary or Managed application, use the following keys: /RunModeOrdinaryApplication launch the thick client in normal mode, despite the configuration settings and... 3
It is necessary that users cannot change the interface configured for them! Solution: To disable it, you need to remove the “Save user data” right from the access rights of the root configuration element. ... 2
In current work, the user usually opens several objects. This could be a document, reference book, report, etc. In the previous interface there were no problems quickly finding open object and update it for... 2
In the previous article: Installing an address classifier (KLADR) in 1C, I told you what KLADR is and how to load it into 1C regular forms (8.0-8.2). In this article I will tell you how to load the Address Classifier (KLADR) into... 2
Often when developing a certain configuration, users want to attach photos to a directory element and have them stored in the database. In this article I will tell you how to connect construction objects to the directory...

The Syntax Helper for these commands states that if the configuration property Mode of UseModalities installed in Do not use, then you should use other commands in your program code, such as ShowQuestion(), ShowWarning(), ShowNumberInput():

To work with these situations, the 1C 8.3 program provides a new system object “Alert Description”, which is used to describe the procedure call software module when some expected event occurs, such as closing a form or a modeless dialog:

This is an inside look at the problem for those who want to get to the root cause. First of all, for 1C programmers. In this situation, how can ordinary users fix the error without working on the program code? There is a very simple method.

Instructions for correcting the error for ordinary users

Step 1: Finish:

Step 2. Return to the start menu to start the configuration. Select the “Configuration” menu item:

Step 3. Open the “Configurator”: on the top panel we find the “Configuration” button, and in the proposed list select the “Open configuration” menu:

Step 4. Place the cursor on Configuration and use the right mouse button to call context menu, in which we select the “Properties” item:

Step 5. Open the “Properties” form:

Step 6. Find the line “Mode of using modality” (at the bottom of the list):

By default, the 1C 8.3 program is set to “Do not use”. Convert the value “Do not use” to the value “Use”:

Result:

If the error “The use of modal windows in this mode is prohibited” in 1C 8.3 has gone away, then you can continue working. This is usually what happens.

But if the modality error in 1C remains after performing all these steps, then you should contact the programmers who service and support your 1C program.

How to work in the “Taxi” interface, how to customize the workplace, customizing the Favorites navigation bar, how to perform full-text search, techniques for working with logs, the “select” button in documents, sending links to documents, verification and other features in new interface - you can learn all this from our video:

Learn more about how to correctly and quickly organize navigation through the 1C 8.3 program using new interface TAXI, new opportunities for using familiar tools, such as a built-in calculator, calendar, file comparison, transferring links to documents to colleagues are discussed in our course ““


Please rate this article:

“The use of modal windows in this mode is prohibited” - this error is now beginning to bother 1C users and programmers with the arrival of the new interface of the 1C 8.3 platform - “ “.

Developers of the 1C technology platform keep up with the times, standardizing their solution to global development standards software. All standards in one way or another come down to a single interface, close to web pages.

Modal and pop-up windows are considered bad form and have long ceased to be normal in software development. Users are accustomed to working “in one window”.

We especially often see a modality error in the following 1C methods:

  • Question;
  • Warning;
  • OpenValue.

With the release of the new “taxi” interface, the developers of the 1C 8 platform made the right decision - to try to retrain application solution developers in a new way. They included a feature in the new platform - “modality mode”.

Quick fix

If you don’t have time to figure it out and need to quickly solve the problem, we offer a simple, but not entirely correct solution. To quickly fix the error, just change the modality mode in the configuration properties.

To do this, log into the system in mode, open the configuration:

In an open configuration, call the context menu by right-clicking on the configuration root and selecting “Properties”:

Get 267 video lessons on 1C for free:

The configuration properties will open, where in the footer there is the property we are interested in - “Modality use mode”, select the “Use” mode:

After that, save and apply the changes by pressing the “F7” key.

Correct solution to the problem

The correct way to solve this problem is to modify the configuration or external processing to new requirements.

Warning, question, dialog boxes and other modal windows - all this needs to be rewritten in a new way.

The built-in operators that called modal windows need to be replaced with duplicate functions.

For example:

  • Warning - ShowWarning;
  • Question - ShowQuestion (details - );
  • — ShowInputNumbers.

At the same time, a specialized object appeared - Notification Description.

Replacement example:

String = "" ; EnterString(String,"Enter a string value"

) Notify("You entered " + String);

Must be replaced with: String = "" ; DescriptionAlerts = New DescriptionAlerts( EnterString(String,) ;

"TestLineInput"

, ThisForm) ;

ShowLineInput(DescriptionAlerts, String,

To block access to the called form by opening a form, just specify the value “Block owner window” in the form property “WindowOpenMode”:

In the configuration properties on the 1C:Enterprise 8.3 platform there is a Mode for using modality. If the value of this field is "Do not use", then when you try to open a modal window, the platform will display the message "The use of modal windows in this mode is prohibited." In this case, the execution of the program code stops.

This article shows the mechanism for changing program code, using the example of a question to the user when the modal mode is disabled.

From time to time, when developing a software product, there is a need to ask the user about the actions being performed. For example, with automatic filling tabular parts. When, before refilling the PM, it is necessary to ask the user about the need to do this. And depending on his answer, the PM will be cleared and refilled, or not.

The question portion of the code might look something like this:

If PM. Quantity()< >0 Then Answer = Question(" // This line will display a modal window with a question and code execution will stop until the user answers If Answer = DialogReturnCode. No Then Return ; EndIf ;// User agrees to continue PM. Clear() ; EndIf ;// Perform further actions

// The program will go here if the PM was empty or the user answered positively to the question about refilling

Perform Further Actions () ;

When modal mode is disabled, an error will occur in the question line of this code and further execution will be interrupted. This will happen because the Question function uses a modal window.

In this situation, you must use the ShowQuestion procedure. This procedure does not wait for the user's response to complete. But the first parameter of this procedure is the description of the alert, which is used to track the user's response. How the previously written code will change:// It is necessary to fill in the PM data< >// Checking the PM for fullness If PM. Quantity() 0 Then // PM is not empty, you need to ask the user about refilling ShowQuestion(New DescriptionAlerts(" Refill TCCompletion" , ThisObject, AdditionalParameters) , " The PM will be refilled. Continue ? ", Dialogue ModeQuestion. YesNo) ; Perform Further Actions() ; EndIf ; // The program will get here in any case, whether the PM was empty or not . . . // (unless, of course, there was an error in the previous code) // Export procedure in the same module// Called after the user answers the question & On the Client Procedure Refill TCCompletion (Response Result, Additional Parameters) Export If Response Result = Dialogue Return Code. No Then// The user refused to continue Return ; EndIf ; // Perform further actions// The program will go here if the PM was not empty and the user answered positively to the question about refilling

PM. Clear() ;
Perform Further Actions() ; End of Procedure Thus, since the program will not stop when the ShowQuestion procedure is executed, it is necessary to carefully handle all events
When solving this problem, performing
further actions

can happen under two events:
1. If the PM was empty

2. If the PM was not empty and the user responded positively to the question, refill

Therefore, as a rule, all executable methods that need to be performed after checking the PM for completeness are placed in a separate procedure.