cancel
Showing results for 
Search instead for 
Did you mean: 

Not able to create Autometic Groups by Site manager

deeps
Champ in-the-making
Champ in-the-making
Hi all,

I have written one js for creating automatic groups in alfresco. and i am executing that js while Folder or market is created by site manager. and in this case its not creating group.

but when i am executing that js while folder is created by admin,  then it executes properly, and also creates group automatically.

So whats wrong with site manager???
i have given coordinator rights for site manager, and its highest right.

can any one help me??
i am using alfresco "5.0 d community"

please reply.

Thanks in advance Smiley Sad





I am using below code in js-

   var logFile2 = space.childByNamePath("logs.txt");
   if (logFile2 == null) {
      logFile2 = space.createFile("logs.txt");
   }
    logFile2.content = "Script execution Started\n";
   logFile2.content+="Folder Name="+space.properties.name;
   
   var nodes=space.childFileFolders();
   try{
      for(var n in nodes){   
      var nodeReference=nodes[n].nodeRef;
         //logFile2.content+="\n\n"+n+" "+nodes[n].name+" "+nodeReference;
         var foundNode = search.findNode(nodeReference);
         try{
            if(foundNode.isContainer){
               logFile2.content+="\n\n"+n+" "+nodes[n].name+" "+nodeReference;
               var parentGroup = groups.getGroup("grp_pf_all_users");
               var grp_name="grp_pf_"+foundNode.properties.name;
               var readGroup = groups.getGroup(grp_name.toLowerCase()+"_read");  //groups.getGroup returns ScriptGroup 
               if(readGroup==null){
                  //readGroup= parentGroup.createGroup(grp_name.toLowerCase()+"_read",grp_name.toLowerCase()+"_read");
               }
               var writeGroup = groups.getGroup(grp_name.toLowerCase()+"_write"); //groups.getGroup returns ScriptGroup 
               if(writeGroup==null){
                  //writeGroup=parentGroup.createGroup(grp_name.toLowerCase()+"_write",grp_name.toLowerCase()+"_write");
               }
            }
         }catch(err){
            logFile2.content+= "\nError to add user read group  "+err ;
         }
      }
   }catch(err){
      logFile2.content+= "\nError to add user read group  "+err ;
   }
4 REPLIES 4

douglascrp
World-Class Innovator
World-Class Innovator
It is a permission problem.
Just like you said, "but when i am executing that js while folder is created by admin, then it executes properly, and also creates group automatically."

The site manager is not an Alfresco administrator user, and because of that, he can't create new groups.

deeps
Champ in-the-making
Champ in-the-making
Hi douglascrp,

actually it was our requirement, and we have to create those groups by site manager only.

but we achieved it through java class.

now its working fine,
and now those groups are also created by site manager…..   Smiley Happy  Smiley Happy

Thanks Smiley Happy

muralidharand
Star Contributor
Star Contributor
Have you used AuthenticationUtil.RunAs or how you've achieved it in Java? Just share some of the code snippets, it may help someone.

deeps
Champ in-the-making
Champ in-the-making
We wrote one evaluator for it, created jar file via eclipse. and using that jar file we executed js by site manager with admin permissions.

now its fine..

if any one need more help then they can contact me.

i will provide you the source code and proper steps to do this.



Thanks,
Deepak