Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Next revisionBoth sides next revision
73:admin_jobs [2019/03/25 19:41] – created emr73:admin_jobs [2019/03/25 19:45] emr
Line 1: Line 1:
-Manage Administrative Jobs+====== 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 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: 
 +<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])); 
 +        } 
 +    } 
 +
 +</code> 
 + 
 +Sample scripts can be downloaded here: 
 + 
 +  * {{:73:userroleassignment.txt|Role assignment}}  via an Excel sheet that is managed as a file instance in a Stages process 
 +  * {{:73:dataexport.txt|Data export}}  to an external SQL table 
 + 
 +Please note, that these scripts are just samples and __need to be adjusted__  to your local environment to be run. 
 + 
 +Future Stages versions will allow to also perform other administrative tasks.