cancel
Showing results for 
Search instead for 
Did you mean: 

Check the group of the creator

roseta
Champ in-the-making
Champ in-the-making
I'm working with advanced workflows in xml files. In a certain node of my workflow, I would like to copy the document into a folder called "Professor" if the creator or the document is a professor, or to a folder called "student" if the creator is a student. I already know how to create folders and move docuements from a folder to another with Java Script, but my question is: How can I check to wich group belongs the creator or the document involved in my workflow?

This is the piece of my processdefinition.xml where I have to insert that piece of code I don't know…



<task-node name="reviewDocument">
        <task name="new:reviewDocumentTask" swimlane="reviewer">
        </task>
        <transition name="accept" to="end">
            <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
               <runas>admin</runas>
                  <script>
                          <variable name="bpm_package" access="read" />
                          <expression>

                      if   ????????????

                          var origin = bpm_package.children[0].parent;
                          var root = origin.parent;
                          var destination = root.childByNamePath("Professor");
                          for (var i=0; i &lt; bpm_package.children.length; i++)
                          {
                              bpm_package.children[i].move(destination);
                          } 

                    else if  ???????????'

                          var origin = bpm_package.children[0].parent;
                          var root = origin.parent;
                          var destination = root.childByNamePath("Student");
                          for (var i=0; i &lt; bpm_package.children.length; i++)
                          {
                              bpm_package.children[i].move(destination);
                          }  

                  
                          </expression>
                  </script>
            </action>
   </transition>
2 REPLIES 2

matjazmuhic
Champ on-the-rise
Champ on-the-rise
Something like this (test it, I didn't tried this)…

var youruser = document.creator; // get your user from somewhere, don't know if this works…
var g = getGroup("Students");
var users = g.getAllUsers();
var i;
for(i=0; i<users.length; i++)
{
if(users[i] =youruser)
{
  …
  move folder code here
  …
}
}

roseta
Champ in-the-making
Champ in-the-making
I've tryed it and doesn't work… The error I get in the log file is: "document" doesn't exist.

How can I definde the document as the current document involved in the workflow??? Help, please!