Workflows through JavaScript

This has a good description of the methods available in Alfresco to do stuff with the workflows;

To make this work;
– create a Javascript file in the data dictionairy and enter the code below.
– Make sure there is a workflow available.
+ check : http://localhost:8080/alfresco/faces/jsp/admin/workflow-console.jsp
+ Enter show definitions all
  + fill in the name in the first line.
– It needs also an active workflow to get stuff like InstanceID.

var naam_wf = “wf:ADHOC”;            // name of the processdefinition of the workflow
var workflowType = “jbpm$” + naam_wf;

var wf_all_definition = workflow.getAllDefinitions();
logger.log(“REPORT – ALL_DEFINITIONS =”+ wf_all_definition);
var wf_definition = workflow.getDefinitionByName(workflowType);
logger.log(“REPORT – DEFINITION =”+ wf_definition);
var wf_description = wf_definition.getDescription();
logger.log(“REPORT – DESCRIPTION =”+ wf_description);
var wf_definition_id = wf_definition.getId();
logger.log(“REPORT – (ADHOC) ID =”+ wf_definition_id);
var wf_instances = wf_definition.getActiveInstances();
logger.log(“REPORT – INSTANCE =”+ wf_instances);
var wf_instance_id = wf_instances[0].getId();
logger.log(“REPORT – INSTANCE_ID =”+ wf_instance_id);
var wf_instance_paths = wf_instances[0].getPaths();
logger.log(“REPORT – PATHS =”+ wf_instance_paths);
var wf_tasks = wf_instance_paths[0].getTasks();
logger.log(“REPORT – TASKS =”+ wf_tasks);
var wf_tasks_length = wf_tasks.length;
logger.log(“REPORT – NUMBER OF TASKS = “+ wf_tasks_length);
var wf_task_name = wf_tasks[0].getDescription();
logger.log(“REPORT – TASK[0] – DESCRIPTION =”+ wf_task_name);



Geef een reactie

Vul je gegevens in of klik op een icoon om in te loggen. logo

Je reageert onder je account. Log uit /  Bijwerken )

Google+ photo

Je reageert onder je Google+ account. Log uit /  Bijwerken )


Je reageert onder je Twitter account. Log uit /  Bijwerken )

Facebook foto

Je reageert onder je Facebook account. Log uit /  Bijwerken )


Verbinden met %s