AnsweredAssumed Answered

How to get username of the person to execute a task

Question asked by xena on Nov 11, 2010
Latest reply on Nov 23, 2010 by giorgio
Hello!
I created an advanced workflow in which the approval task is assigned to the group "approvers" who are the Project Manager.
I also created an aspect "utente" that should show the username of the project manager who has taken over the task of approval. How can I do?
This is the code:
<swimlane name="approvers">
           <assignment class="org.alfresco.repo.workflow.jbpm.AlfrescoAssignment">
                  <pooledactors>#{people.getGroup('GROUP_ProjectManager')}
      </pooledactors>
   </assignment>
   </swimlane>


<task-node name="Validazione">
   <event type="node-enter">
           <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
               <runas>admin</runas>
               <script>
                   for (var i = 0; i &lt; bpm_package.children.length; i++)
                   {
                      bpm_package.children[i].properties["wfpm:status"] = "Verificato";
                      bpm_package.children[i].save();
                   }
               </script>
           </action>
       </event>
         <event type="node-leave">
           <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
             <runas>admin</runas>
               <script>
                   for (var i = 0; i &lt; bpm_package.children.length; i++)
                   {
                          if (!bpm_package.children[i].hasAspect("wfpm:utente"))
                      {
                         bpm_package.children[i].addAspect("wfpm:utente");
                      }
                   }
                    </script>
           </action>
       </event>
      <transition to="Rifiutato" name="Rifiuta"></transition>
      <transition to="Validato" name="Valida"></transition>
         <task name="wfpm:validazioneTask" swimlane="approvers" />
   </task-node>

<task-node name="Validato">
     <event type="node-enter">
           <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
               <runas>admin</runas>
                <script>
                   //first proof
                   //var utente=people.getPerson(people.getGroup('GROUP_ProjectManager'))).properties.userName;

                    //second proof
                        var utente=people.getPerson(approvers).properties.userName;


                    for (var i = 0; i &lt; bpm_package.children.length; i++)
                   {
                       bpm_package.children[i].properties["wfpm:utente"] = utente;
                      bpm_package.children[i].properties["wfpm:status"] = "Validato";
                      bpm_package.children[i].save();
                   }
                </script>
           </action>
       </event>
   <task name="wfpm:ValidatoTask" swimlane="initiator" />
<transition to="End" name="termina"></transition>
</task-node>
During the validation task, when I click , the button "Valida"
In the first case gives me the error: TypeError: Can not read property "properties" from null (AlfrescoJS # 1)
In the second case the error is: ReferenceError: "approvers" is not defined. (AlfrescoJS # 1)
Any suggestions??

Outcomes