Create On-demand Server Automation Scripts

  1. In FintechOS Studio, go to Main Menu > Advanced > Server Automation Scripts.
  2. Click Insert. The Add Server Automation Script page appears.
  3. In the General tab, enter a unique Name for the automation script.
  4. In the Description field type a description of the automation script logic. The field is optional, but we recommend you to provide a description, so that developers have a clear view on what the automation script is intended to do.
  5. From the Script Type drop-down, select On-Demand.
  6. In the Code field, enter the automation script code (using Server SDK functions). If you want to use Server Automation Script Libraries, you can do so, by calling functions defined in the library.
  7. Copy
    //parameter called input1 received from client <a href="">callActionByName</a> function
    var input1 = context.Data.input1;

    //call to a method defined in server script library
    var cnt = new FTOSExample().getCount();

    //the custom returned object
    var acc = {totalCount: cnt, test:"example1", resInput1: input1};

    //returns data in UI (on callback of the callActionByName))
    To avoid calling the wrong methods and attributes, you can use the ‘$m’ mechanism when writing the code. For more information, see Code Snippets Support for JavaScript.
    If you want to use an automation script library (the one whose functions you appended in the Code field), after saving the automation script, go to the Edit Automation Script page and, in the List of Automation Script Libraries section, click the Insert existing button and select the desired script library by double-clicking it.
  8. Click Save and reload. This will enable the Server Automation Script Libraries and the Endpoints sections at the bottom of the page.
  9. Use the Server Automation Script Libraries section to select any Server Automation Script Libraries your automation script uses.
  10. Use the Endpoints section to define any Endpoints that call the automation script.
  11. Click Save and reload.

Customize the Input Parameters

You can define mandatory input parameters that must be passed to the script by the client process and you can enable intelligent code completion in the code editor for the script's input parameters. Input parameters are typically passed to the automation script by a client side script using an ebs.callAction type of function, or by an API call using the CallAction endpoint.

To define an input parameter:

  1. Open the automation script in the editor and select the Input Parameters tab.
  2. In the Workflow Input Parameters list, click Insert to add a new parameter to the list.
  3. Fill in the input parameter's details:
  4. Click Save and close.

Once defined as above, you can use the context.parameters property in the code editor to access the script's input parameters with intelligent code completion.

Customize the Output Structure

You can customize the script's output structure to enable intelligent code completion for the result passed to the client-side callback function. You can map the output structure to an entity data model, or you can define your own custom structure. Also, you can specify if the output is in the form of a single object instance, or if it is a collection of objects each matching this output structure.

To define the script's output structure:

  1. Open the automation script in the editor and select the Output Structure tab.

  2. Select the Output Structure Type:
    • Entity - The output structure is based on an entity data model, matching the entity's attributes' names and types.
    • Custom - Select this option if you wish to define the script's output structure manually.
    • Boolean - Select this option if the script returns either a true or false result, for instance if you wish to use it for validations.
  3. Check the Use Json Schema For Output Structure to use a JSON schema for the output structure field.
  4. Select the Output Parameter Type:
    • Single Instance - The script result is a single object instance.
    • Collection - The script result is a collection of objects.
  5. If you selected an output structure type based on an entity, select the Output Structure Entity. This is the entity providing the data model for the output structure.
  6. If you selected a custom output structure , fill in the Output Structure Custom field in the following format:
        "name1" : "dataType1",
        "name2" : "dataType2"
    If you checked the Use Json Schema For Output Structure box, add in the Output Structure Custom field a JSON schema or create one from a JSON object using the Generate JSON schema button as mentioned in the Customize the Input Parameters section.
  7. If you wish to support null values for the output structure, tick the Allow Null Value checkbox.
  8. Click Save and close.

After you define the output structure as above, you can use the createResult() and createResultItem() constructors to create result objects with intelligent code completion in the code editor.

You can attach the result object(s) to the context.result property which is passed to the client-side callback function.

var res = createResult();
res.Name = 'test name';
res.Email = '';

context.result = res;
var item1 = createResultItem();
item1.Name = 'test name';
item1.Email = '';

var item2 = createResultItem({
    Name : 'test name 2',
    Email : ''