You can add JavaScript functions to your web screens, web blocks, or to the eSpace and use them, for example, in a widget extended property. These three scope where you can write your JavaScript functions are important, as they allow you to structure your JavaScript code throughout your application.

In Service Studio, JavaScript functions are defined locally for a Web Screen or Web Block, or globally for the eSpace. Once the functions are defined, simply invoke them as values of eSpace elements extended properties. Since the value of a property is an expression, you can also type the JavaScript source code directly in the extended property value. See how to Extend Properties.

To handle JavaScript errors add and register error handler JavaScript functions. How?.

In some situations, you might still need to use un-escaped expressions.

Web Screen, Web Block, and Module Javascript

The JavaScript code that you add can be local to a Web Screen or Web Block, or global to the eSpace. The local JavaScript can only be used within the Web Screen or Web Block where it is defined, while the eSpace global JavaScript can be used in any Web Screen or Web Block of the eSpace.

How to add JavaScript functions to your elements:

  • To edit the JavaScript functions you should use the JavaScript editor. To open it click on in the JavaScript property of the element.

At runtime, both the Web Screen/Web Block and eSpace JavaScript code are placed in a separate file that is included in each HTML page generated by the Platform Server.

Furthermore, since the local JavaScript functions scope is the whole Web Screen or Web Block, you can use them elsewhere in that screen or block, for example in un-escaped expressions.

In the example below, you have a JavaScript function that is invoked when the onclick event occurs.

An example of a web block JavaScript function to alert the user for some problem with the header data is:

See Also

Handling JavaScript Errors | Extending Properties | JavaScript Editor | eSpace Properties | Un-escape Expression Contents