Javascript Support of the OutSystems Platform

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

In the 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 with the Extended Properties editor. Since the value of a property is an expression, you can also type the JavaScript source code directly in the value extended property value.

Or even you can include the .js files in your eSpace as resources mantaining their original directory structure by using OmlResources. That way, when your eSpace is deployed, these files will be copied to the running application directory with the same directory structure they were imported. For example, if you execute "OmlResources -o eSpace.oml -add dir\file.js", you can then reference the javascript file in your pages as "dir/file.js". To do the include you can add a <script> to your WebScreen using an unescaped expression, or better, in the Preparation of your WebScreen call the Action "AddJavaScriptTag" of the Extension HTTPRequestHandler. This way you'll have a include in the <head> section of the html.

You can also add Javascript resources through Integration Studio adding the references to your solution and maintaining the javascript library outside your eSpace.

For deeper instructions on how to use Javascript on OutSystems Applications, please refer to the Service Studio Help.