Manage Administrative Jobs

Some administrative jobs should be executed on a regular basis. For that purpose, administrative jobs like role assignments or data exports can be run automatically.

Administrators can upload scripts via the Administration > Jobs and select the execution frequence via a cron expression. The scripts are executed on the Stages server under the id of the user that uploaded the script.

The existing Facade API can be used to navigate through the process content. For example, to assign a user named userName to a role named roleName in a workspace workspacePath, use the following code:

var user = stages.getUserByUsername(userName);
var project = stages.getProjectByPath(workspacePath);
if (user != null && project != null) {
    var roles = project.getEntities("containsProcess@SYSTEM")[0].getEntities("containsRole@SYSTEM");
    for (var i = 0; i <roles.length; i++) {
   var role = roles[i];
        if (role.getProperty("DisplayName") == roleName) {
            commands.execute(commands.newAssignUserCommand(role, [user]));
        }
    }
}

Sample scripts can be downloaded here:

Please note, that these scripts are just samples and need to be adjusted to your local environment to be run.