Server calls in form events (ServerCallsInFormEvents)¶
| Type | Scope | Severity | Activated by default |
Minutes to fix |
Tags |
|---|---|---|---|---|---|
Error |
BSL |
Critical |
Yes |
15 |
design |
Description¶
Events OnActivateRow and OnStartChoice should not contain contextual server procedure calls. These events should only execute on the client.
Only server calls to methods of this form executed within the server context (&AtServer) are diagnosed. Calling general modules (e.g., MyModuleServer.MyServerMethod) or non-contextual server procedures of the form itself (&AtServerNoContext) will not result in an error.
According to the Infostart article, calling server procedures from these events can lead to performance issues and form behavior problems.
Examples¶
Incorrect¶
&AtClient
Procedure OnActivateRow(Element, SelectedRow, Field, NewValue, StandardProcessing)
// Error: server procedure call from client event
TableFormOnActivateRowAtServer();
StandardProcessing = False;
EndProcedure
&AtServer
Procedure TableFormOnActivateRowAtServer()
RaiseException "test";
EndProcedure
Correct¶
&AtClient
Procedure OnActivateRow(Element, SelectedRow, Field, NewValue, StandardProcessing)
// Correct: only client processing
StandardProcessing = False;
EndProcedure
&AtServerNoContext
Procedure OnActivateRow(Element, SelectedRow, Field, NewValue, StandardProcessing)
// Correct: non-context server form calls are allowed
StandardProcessing = False;
EndProcedure
Sources¶
Snippets¶
Diagnostic ignorance in code¶
// BSLLS:ServerCallsInFormEvents-off
// BSLLS:ServerCallsInFormEvents-on
Parameter for config¶
"ServerCallsInFormEvents": false