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”>
<value>{http://www.alfresco.org}onCreateNode</value>
</property>
<property name=”className”>
<value>{http://www.alfresco.org/model/content/1.0}folder</value>
</property>
<property name=”behaviour”>
<bean class=”org.alfresco.repo.jscript.ScriptBehaviour” parent=”scriptBehaviour”>
<property name=”location”>
<bean class=”org.alfresco.repo.jscript.ClasspathScriptLocation”>
<constructor-arg><value>alfresco/extension/scripts/behaviours/aaa_onCreateNode.js</value></constructor-arg>
</bean>
</property>
</bean>
</property>
</bean>

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 (behaviour.name != null && behaviour.name == “onCreateNode”){
var childAssoc = behaviour.args[0];
var node = childAssoc.getChild();
var companyhome = search.findNode(“path”, [‘workspace’,’SpacesStore’,’app:company_home’]);

}

 

 

Advertenties

Geef een reactie

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

WordPress.com logo

Je reageert onder je WordPress.com account. Log uit / Bijwerken )

Twitter-afbeelding

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

Facebook foto

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

Google+ photo

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

Verbinden met %s