Workflows through JavaScript

This has a good description of the methods available in Alfresco to do stuff with the workflows; http://wiki.alfresco.com/wiki/Workflow_JavaScript_API

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);

 

Advertenties

Custom Model

Since I always forget ;

I update this one : …./config/extension/model/customModel.xml
The …./config/extension/custom-model-context.xml is still the same (contains a bean referring to the above file)

I have to update the web-client-config-custom.xml and add
– my newly defined types to the list of the Content Wizards
– my newly defined aspects to the list of the Action Wizards
– then define all types here with their properties showing
– then define all aspects with their properties and associations showing

And this is enough to update the custom model

(no) logging in workflow

I’m trying to achieve logging from javascript code in a workflow, but with no success.
This is an excerpt from the workflow code I’m using:

<event type=”process-start”>
<action>
<script>
logger.log(“Message X”);
</script>
</action>
</event>

C:\alfresco-enterprise-tomcat-3.4.4\tomcat\webapps\alfresco\WEB-INF\classes\log4j.properties
contains:
      log4j.logger.org.alfresco.repo.workflow=DEBUG 

That should be good, but no logging information.

https://forums.alfresco.com/en/viewtopic.php?f=10&t=21838 gave me the answer.

# Repository
….
log4j.logger.org.alfresco.repo.jscript=error
log4j.logger.org.alfresco.repo.jscript.ScriptLogger=debug    <= set this one .
log4j.logger.org.alfresco.rep…..

And also –

My script needs to be encapsulated by the action class AlfrescoJavaScript.

<action class=”org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript”>
<script>
logger.log(“Ad Hoc Task”);
</script>
</action>

Workflow console

The link to my personal workflow console ; http://localhost:8080/alfresco/faces/jsp/admin/workflow-console.jsp

I`m testing all kinds of variations of workflows. (simple workflow, but mostly variations of the advanced workflow) Because trial and error clutters up my Alfresco environment, I want to clean up all the old (non-working) workflows.

If I understood correctly Alfresco does not delete the older workflows. If a workflow crashed (due to any number of reasons – aka wrong names, unreachable variables, wrongly defined names etc.) the workflow step is kept alive in the system. This is great for produktion systems, but for testing it’s not that convenient.

So i`ll delete them through the management console.

show definitions all     – show me all workflows that still exist in the system

delete all workflows imeanit   –  my personal favorite, but a ruthless one..

undeploy definition name jbpm$incentroWorkflow – remove this workflow from the system.

undeploy definition jbpm$26  – remove workflow with this number

Using the Adhoc workflow model

I’ve created the adhoc model from the wiki example; http://wiki.alfresco.com/wiki/WorkflowAdministration

I created 3 files and it’s working (hooray)

C:\alfresco-enterprise-tomcat-3.4.4\tomcat\shared\classes\alfresco\extension\custom-workflow-context.xml

C:\alfresco-enterprise-tomcat-3.4.4\tomcat\shared\classes\alfresco\extension\workflow\adhoc\adhocModel.xml

C:\alfresco-enterprise-tomcat-3.4.4\tomcat\shared\classes\alfresco\extension\workflow\adhoc\processdefinition.xml

– the content of the files can be found at the above named wiki page

Now I want to place the functions in my own name space (incentro of course) and this seems to be an issue. It’s not working.. I haven’t figured out why yet. Just renaming the wf:prefix with an incentro:prefix did not work. There must be something I am missing….

More workflows in Alfresco

Still working on workflows;

This is  good example to make a workflow with a lifecycle.

http://wiki.alfresco.com/wiki/WorkflowSample_Lifecycle

I only run into some issues with user authentication. If I start a workflow (as admin) on a txt document and refer it to a user (myself) there are some authentication errors. It might have something to do with this code;

<swimlane name=”reviewer”>
<assignment class=”org.alfresco.repo.workflow.jbpm.AlfrescoAssignment”>
<actor>#{bpm_assignee}</actor>
</assignment>
</swimlane>

I have no solution yet.. So back to research..

Workflows

I am following the http://wiki.alfresco.com/wiki/WorkflowAdministration step-by-step guide to creating a custom workflow.

The anwser to my question, regarding how to get / where to place a new custom-workflow-context.xml file got answered in this very usefull forum topic –  https://forums.alfresco.com/en/viewtopic.php?f=30&t=35459

I am once again a little frustrated with the Alfresco system.
Why? The “hello world” workflow won’t work… The simplest.xml workflow didn’t work.
And “A system error happened during the operation: null”  is not really a good error in my humble opinion.