cancel
Showing results for 
Search instead for 
Did you mean: 

[SOLVED]Companyhome and initiatorhome is UNDEFINED

chicco0386
Champ on-the-rise
Champ on-the-rise
Hi,
in my workflow I must to move the document into the right folder during the wf.
For the two step I can do this, but at the thirty step I read that companyhome and initiatorhome is UNDEFINED  :shock:  :shock:  :shock:  :shock:  Smiley Surprised  Smiley Surprised  Smiley Surprised  Smiley Surprised
HOW IT'S POSSIBLE?

this is my code:
<task-node name="Riscrittura">
      <task name="wfEnteP:Riscrittura" swimlane="riscrittura"/>
      <transition to="Redazione" name="ChiediRedazione">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               <runas>admin</runas>
               <variable name="bpm_package" access="read"></variable>
               <variable name="initiatorhome" access="read,write"></variable>
               <expression>
                  var destRedazione = initiatorhome.childByNamePath("/5) Ufficio redazione/Da redare");
                  for (i = 0; i &lt; bpm_package.children.length; i++){
                     bpm_package.children[i].move(destRedazione);
                  }
               </expression>
            </script>
         </action>
      </transition>
   </task-node>

So if the companyhome and the initiatorhome is undefined I CAN'T use the childByNamePath() function….

CAN YOU HELP ME PLEASE?
I TRY ALL SOLUTIONS?
I ATTEND :cry:  :cry:

P.S. sorry for my english
2 REPLIES 2

chicco0386
Champ on-the-rise
Champ on-the-rise
PLEASE I need help…
Now I explain me better.

My wf is this:
[img]http://img190.imageshack.us/img190/8862/processimage.jpg[/img]

Now:
1) Inizio –> ControlloCorrettezza: I move and copy the documents into 2 different folder (OK)
<start-state name="Inizio">
      <task name="wfEnteP:inizia" swimlane="initiator"></task>
      <transition to="ControlloCorrettezza" name="ChiediCorrettezza">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               <runas>admin</runas>
               <variable name="bpm_package" access="read"></variable>
               <variable name="companyhome" access="read,write"></variable>
               <!– Il seguente script mi fa la copy nella cartella "Ufficio Correttezza"
               e la move nella cartella "Ufficio lettura" dei documenti interessati
               nel workflow –>
               <expression>
                  var destCorrettezza = companyhome.childByNamePath("Ente Pubblico/3) Ufficio correttezza");
                  var destLettura = companyhome.childByNamePath("/Ente Pubblico/2) Ufficio lettura");
                  /*Ciclo per copiare e muovere i TUTTI i doc del wf se presenti più di uno*/
                  for (i = 0; i &lt; bpm_package.children.length; i++){
                     bpm_package.children[i].copy(destLettura);
                     bpm_package.children[i].move(destCorrettezza);
                  }
               </expression>
            </script>
         </action>
      </transition>
   </start-state>
2) ControlloCorrettezza –> Riscrittura: I move the document in a folder (OK) in this step companyhome result INDEFINED, so I use initiatorhome
<task-node name="ControlloCorrettezza">
      <task name="wfEnteP:ControlloCorrettezza" swimlane="correttezza"></task>
      <transition to="Riscrittura" name="ChiediRiscrittura">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               <runas>admin</runas>
               <variable name="bpm_package" access="read"></variable>
               <variable name="initiatorhome" access="read,write"></variable>
               <expression>
                  var destCorretto = initiatorhome.childByNamePath("/4) Ufficio riscrittura");
                  for (i = 0;i &lt; bpm_package.children.length; i++){
                     bpm_package.children[i].move(destCorretto);
                  }
               </expression>
            </script>
         </action>
      </transition>
      <transition to="Rifiuto" name="Rifiutato">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               <runas>admin</runas>
               <variable name="bpm_package" access="read"></variable>
               <variable name="initiatorhome" access="read,write"></variable>
               <expression>
                  var destRifiutati = initiatorhome.childByNamePath("/1) Ufficio protocollo/Respinti");
                  for (i = 0;i &lt; bpm_package.children.length; i++){
                     bpm_package.children[i].move(destRifiutati);
                  }
               </expression>
            </script>
         </action>
      </transition>
   </task-node>

3)Riscrittura – > Redazione: I move the document in a folder
THE PROBLEM IS HERE: in this transition and also in the after transitions I CAN'T move the document using companyhome and initiatorhome, because if I print in the log file their names (logger.log (companyhome.name+initiatorhome.name)) the results are that all two are UNDEFINED, SO I CAN'T USE childByNamePath metod.
<task-node name="Riscrittura">
      <task name="wfEnteP:Riscrittura" swimlane="riscrittura"/>
      <transition to="Redazione" name="ChiediRedazione">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               <runas>admin</runas>
               <variable name="bpm_package" access="read"></variable>
               <variable name="companyhome" access="read,write"></variable>
               <variable name="initiator" access="read"></variable>
               <expression>
                  logger.log(initiator.name);
                  var destRedazione = companyhome.childByNamePath("/Ente Pubblico/5) Ufficio redazione/Da redare");
                  for (i = 0; i &lt; bpm_package.children.length; i++){
                     bpm_package.children[i].move(destRedazione);
                  }
               </expression>
            </script>
         </action>
      </transition>

HELP ME PLEASE
THANKS

sorry my english

chicco0386
Champ on-the-rise
Champ on-the-rise
SOLVED:
I've set the access permission on the declaration of variables in write…THIS IS THE ERROR

SO I'VE SOLVED LIKE THIS:

<variable name="companyhome" access="read"></variable>

Or simply:

<start-state name="Inizio">
      <task name="wfEnteP:inizia" swimlane="initiator"></task>
      <transition to="ControlloCorrettezza" name="ChiediCorrettezza">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
            <script>
               var destCorrettezza = companyhome.childByNamePath("Ente Pubblico/3) Ufficio correttezza");
               var destLettura = companyhome.childByNamePath("/Ente Pubblico/2) Ufficio lettura");
               /*Ciclo per copiare e muovere i TUTTI i doc del wf se presenti più di uno*/
               for (i = 0; i &lt; bpm_package.children.length; i++){
                  bpm_package.children[i].copy(destLettura);
                  bpm_package.children[i].move(destCorrettezza);
               }
            </script>
         </action>
      </transition>
   </start-state>

Without the expression and variable tag… :mrgreen:  :roll:  :lol:  :x

BYE