Creating On-demand Server Automation Scripts

To create an on-demand server automation script, follow these steps:

  1. From the menu, click Advanced > Server Automation Scripts. The Server Automation Scripts List page appears:
  2. At the top-right corner of the page, click the Insert icon. 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 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 using Server SDK functions). If you want to use an automation script library, 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 for entities and attributes.
    NOTE  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 Edit Automation Script page, from the List of Automation Script Libraries section, click the Insert existing button and select the desired script library by double-clicking it.
  8. At the top-right corner of the page, click the Save and reload () icon to save the automation script. 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 script libraries your automation script uses. For details about automation script libraries, see Using Automation Script Libraries.
  10. Use the Endpoints section to define any endpoints that call the automation script. For more details about endpoints, see Creating Endpoints.
  11. Clic Save and reload ().

Customizing 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 the Insert button to add a new parameter to the list.
  3. Fill in the input parameter's details.
    • Name - Enter a name for the input parameter. The name must match the incoming variable name provided by the client process.
    • Description - Optionally enter a description for the parameter.
    • Data Type - Select the parameter's data type. Currently supported data types are any, numeric, boolean, and string JavaScript object types.
    • Allow null or empty value - Leave empty to make the parameter mandatory for the automation script's execution. Selecting this checkbox makes the parameter optional.
  4. Click the Save and close button () at the top-right corner of the page.

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.

Customizing 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 you 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.
  3. Select the Output Parameter Type:
    • Single Instance - The script result is a single object instance.
    • Collection - The script result is a collection of objects.
  4. 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.
  5. If you selected a custom output structure type, fill in the Output Structure Custom field in the following format:
    export interface IResult
        "name1" : "dataType1",
        "name2" : "dataType2"
  6. Click the Save and close button () at the top-right corner of the page.

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 : ''