Read this before writing scripts


Javascript

All scripts are written in Javascript. See here for an introduction to Javascript.

Current user

The current user is available in all scripts as the object named 'actionUser':

var userMe = actionUser;

Using Java Classes

In our scripty Javascript is a wrapper around Java as the core programming language of todo4teams.

To create new variables or obj́ects from Java classes there are several options:

  • Simply use the new operator:
    var s = new java.lang.String();
  • Declare the Java type in Javascript first and then create the object:

    var StringArray = Java.type("java.lang.String[]");
    var values = new StringArray(2);

  • Use the helper object (available in all script contexts)

    •  

    to create new objects:
    var x = helper.createInstance('com.mycompany.types.MyBusinessObject');

    •  

    or to create arrays in one line:
    var x = helper.createArray('com.mycompany.types.MyBusinessObject', 20);

  • xxx

Accessing common business objects of todo4teams

The helper object offers access to common business objects e.g. the list of users in todo4teams:

var users = helper.getUsers(); // array of all users

var user = helper.getUserById(23);

var user2 = helper.getUserByUserName("jsmith");