Start page / Tutorials / Workflows / Examples for scripts

Examples

Listing of all possible transitions with permissions starting from the current action:

//!Beanshell
 
transitions = context.getTransitions();
print("Number of transitions:" + transitions.length);
 
for (i=0; i<transitions.length; i++) {
  print("Transition:" + transitions[i].getTarget());
  allowedUsers = transitions[i].getAllowedUsers();
  for (j=0; j<allowedUsers.size(); j++) {
    print("Allowed User:" + allowedUsers.get(j));
  }
}

State management in workflow instances (counter):

//!Beanshell
 
state=context.getSession();
v=state.get("test");
if(v==null) v=0;
state.put("test",++v);

Generates an instance for every available workflow:

//!Beanshell
 
import firstspirit.access.store.templatestore.*;
u=context.getUserService();
ts=u.getTemplateStore();
wfs=ts.getWorkflows().getAllChilds(Workflow.class);
 
for (i=0; i<wfs.length; i++) {
    print("Workflow:" + wfs[i].getName());
    try {
       u.createTask(null, wfs[i], wfs[i].getName());
    } catch (Exception e) { print("Error!");}
}

Other methods can be taken from the FirstSpirit Access API.

© 2005 - 2024 Crownpeak Technology GmbH | All rights reserved. | FirstSpirit 2024.12 | Data privacy