Script execution on the client and on the server

In the previous lesson you created a single procedure for handling multiple events and stored it to the common DocumentProcessing module. In particular, you set the Client (managed application) checkbox and cleared the Server checkbox in the module properties. The procedure is called from the form module where the event handler also has a directive that specifies the execution context for this handler: &AtClient. Now we will explain how the script is executed in this scenario.

When an application is started, script execution is always started on the client. Then the script execution can be passed to the server by calling a procedure of a common module compiled on the server.

When a procedure or function is called, the platform searches for it on a client first. If the compiled client context does not contain this procedure, the search continues on the server. If the procedure is found, the script execution is passed to the server. When the procedure is execution is completed, the script execution continues on the client.

For example, when you change a price in a goods receipt form, the PriceOnChange() procedure of the form module is called. It is executed on the client in the thin client mode. The second line of this handler calls the CalculateTotal() procedure. This procedure is located in the common DocumentProcessing module, which is also compiled on the client. It is executed in the thin client mode. Once the procedure is executed, the execution is passed back to the form module (fig. 5.49).

Fig. 5.49. Passing script execution between client modules

Go to the next lesson: Lesson 6 (0:50). Accumulation registers

Be the first to know tips & tricks on business application development!

A confirmation e-mail has been sent to the e-mail address you provided .

Click the link in the e-mail to confirm and activate the subscription.