Description
The predefined Server object is designed to be a point of access to all server-side MetaScript functionality.
The Server object is populated with:
- functions defined in the form's Server-Side MetaScript (if any)
- built-in predefined Server functions
- web service methods
![]() | Requires Form API version 2.2 or greater |
Client-side MetaScript
Syntax
Calling a Server function:
Server[.namespace].server-side-function( argument1, ..., function result-callback( result ) { ... } ); // asynchronous call syntax (preferred)
or
var result = Server[.namespace].server-side-function( argument1, ... ); // synchronous call syntax
Methods
Method | Description |
---|---|
server-side-function | A Server object method defined in the Server-Side MetaScript. |
Parameters
Parameter | Description |
---|---|
argument1, ... | Arguments to be passed to the server-side-function(). |
result-callback | A function to be called when the result is received from the server. Can accept the result as an argument. |
Description
The Server call unfolds into the following "under the hood" steps:
- arguments are serialized to JSON and sent to the server
- the server receives the JSON, de-serializes the arguments and passes them to the server-side-function call
- the server-side-function's return value is serialized to JSON and sent back to the client
- the client receives the return value's JSON, de-serializes it into result argument, and passes it to the result-callback call.
![]() | Under-the-hood usage of JSON means that the arguments and the return value will lose anything that is not data, such as functions etc. |
![]() | The Global MetaScript code should not rely on timing of the result-callback calls: to further increase efficiency of Server interaction, Virtual Ticket may postpone calling the result-callback and allow other Global MetaScript code to run until the Server response is received. |
Server-side MetaScript
Syntax
Defining a Server function:
Server.server-side-function = function( argument1, ... ) { ... }
or:
Server.namespace = {
server-side-function: function( argument1, ... ) { ... }
}
Calling a Server function:
var result = Server[.namespace].server-side-function( argument1, ... );
Description
Calls the server-side-function and returns its return value.
Example
Using server calls to load data for the form.