Skip to content

There is no check for the attribute DataExchange.Load in the object's event handler (DataExchangeLoading)

Type Scope Severity Activated
by default
Minutes
to fix
Tags
Error BSL Critical Yes 5 standard
badpractice
unpredictable

Parameters

Name Type Description Default value
findFirst Boolean Check should go first false

Description

All actions in the event-handler procedures BeforeWrite, OnWrite, BeforeDelete should be performed after checking for DataExchange.Load.

This is necessary so that no business logic of the object is executed when writing the object through the data exchange mechanism, since it has already been executed for the object in the node where it was created. In this case, all data is loaded into the Information Base "as is", without distortion (changes), checks or any other actions that prevent data loading.

Examples

Incorrect:

Procedure BeforeWrite(Cancel) 

     If Not Cancel Then
        RumMyFunction();
    EndIf;

    // other code
    //
    // ...

EndProcedure
Correct:
Procedure BeforeWrite(Cancel) 

     If DataExchange.Load Then
        Return;
    EndIf;

    // other code
    //
    // ...
EndProcedure

Sources

Snippets

Diagnostic ignorance in code

// BSLLS:DataExchangeLoading-off
// BSLLS:DataExchangeLoading-on

Parameter for config

"DataExchangeLoading": {
    "findFirst": false
}