AnsweredAssumed Answered

[solved]Writing a custom behaviour on user create

Question asked by zomurn on Oct 21, 2008
Latest reply on Dec 4, 2008 by daniel.gradecak

I'am writing a custom behavior after reading the good article named "behavior-article.pdf".
So here is what I want to do :

When the administration create a user, I want to "catch the event" (does it correspond to onCreateStore event ?) so to create automticaly two directories in his home space.

So I declared the bean for spring and wrote a "test" javascript to see if it is called. :


<bean id="onCreateUserStore" 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">

onCreateUser.js :

logger.log("Start onCreateUser.js…");
if (behaviour == null) {
   logger.log("The behaviour object has not been set");
//check the name of the behaviour
if ( == null && != "onCreateStore") {
   logger.log("The behaviour name has not been set correctly");
else {
   logger.log("Behaviour name: " +;

//check the arguments
if (behaviour.args == null) {
   logger.log("The args have not been set");
} else {
   if (behaviour.args.length == 1) {
      var user = behaviour.args[0];
      logger.log("init user's workspace");
      logger.log("end user's workspace");

I put the log4j for jscript to debug. When this script is run ? To which act the onCreateStore correspond to ? (is it when a new user is added ?)
More generally, to which action are binded the events ?
I'd like to catch the action on user create …

Thanks for your help !