How to start workflow using java



Picking up new stuff rather quickly now.

It seems I start to understand Alfresco. I can make custom actions, nice action buttons, run Javascripts (inside & outside alfresco) without errors. I can adress spaces & nodes and access their parameters now.

So level up !!!

We now need to find nodes & space within the repository without looking for names. So I created aspect like

– isCollection
– isHidden
– isConfigFile

Based on a location X where I start my script (see previous post how to get that location and context in a Javasscript) I want to find a Space somewhere higher up the tree. And where “before” i searched for a name of a space, i now search for an .hasAspect(“namespace_x:isHidden”) and if that’s true I do my stuff.


in ContentModel.xml adding aspects like this:

<aspect name=”mjb:isPlanning”>
<property name=”mjb:isPlanning”>
<title>MJB Planning</title>
<association name=”mjb:isPlannable”>
<title>Planning Space</title>

how to adres the behaviour variable in a alfresco javascript

I`m making some “On-Create-Folder” behaviour.

– To make things simple i created a “behaviour action” button (aka a custom action) which calls a javascript which I stored in the datadictionairy / scripts folder. This script is stored inside the Alfresco repository. It’s called aaa_onCreateNode.js and  does only this :

logger.log(” GOTCHA from ALFRESCO repository”);

This script is triggered manually by pressing the button.

– I have another script which is located outside the repository & stored on this location: alfresco/extension/scripts/behaviours/aaa_onCreateNode.js
This is running from the classpath

<bean id=”onCreateNode” class=”org.alfresco.repo.policy.registration.ClassPolicyRegistration” parent=”policyRegistration”>
<property name=”policyName”>
<property name=”className”>
<property name=”behaviour”>
<bean class=”org.alfresco.repo.jscript.ScriptBehaviour” parent=”scriptBehaviour”>
<property name=”location”>
<bean class=”org.alfresco.repo.jscript.ClasspathScriptLocation”>

This script is called automatically when I create a new space.

So now I have both scripts up & running, I need to access some environment parameters. I want to know for example from which location I am working from.

The parameter behaviour works for the script which is automatically started (aka the script run from the classpath) So this gives me all the handles I need to do stuff.

if ( != null && == “onCreateNode”){
var childAssoc = behaviour.args[0];
var node = childAssoc.getChild();
var companyhome = search.findNode(“path”, [‘workspace’,’SpacesStore’,’app:company_home’]);