1Ci Support Help Center home page
Submit a request
Sign in
  1. 1Ci Support
  2. 1C:Enterprise Development Standards
  3. Code conventions
  4. Module formatting

Working with Cancel parameter in event handlers

  • Module formatting
    • Module texts
    • Module structure
    • Procedure and function names
    • Procedure and function description
    • Procedure and function parameters
    • Specifics of using structures as procedure and function parameters
    • Rules for variable names generation
    • Working with Cancel parameter in event handlers

Scope: managed applications, mobile applications, and ordinary applications.

1. In event handlers of object modules, record sets, forms, and other that contain the Cancel parameter (OnWrite, FillCheckProcessing, GoodsBeforeAddRow, and other), do not set this parameter to False.
This requirement applies since the Cancel parameter can usually be set in multiple consecutive checks at once (or multiple subscriptions to the same event) in event handler code. In this case, by the time the check is completed, the Cancel parameter might have already had the True value, and thus you can incorrectly reset it to False.
Moreover, the number of these checks can increase upon deployed configuration update.

Incorrect:

Procedure FillCheckProcessing(Cancel, CheckedAttributes)
  ...
  Cancel = HasFillingErrors();
  ...
EndProcedure

Correct:

Procedure FillCheckProcessing(Cancel, CheckedAttributes)
  ...
  If HasFillingErrors() Then
   Cancel = True;
  EndIf;
  ...
EndProcedure

or

Cancel = Cancel Or HasFillingErrors();

2. The same requirements apply to other similar parameters of event handlers: StandardProcessing, Execute, and other.
For example:

Procedure ChoiceDataGetProcessing(ChoiceData, Parameters, StandardProcessing)
 
  If Parameters.Properties(...) Then
    StandardProcessing = False;
    ...
EndIf; EndProcedure
© 2020 1C INTERNATIONAL LLC www.1Ci.com Support policy