cancel
Showing results for 
Search instead for 
Did you mean: 

Copying/Moving of documents in workflow package not working

dennish
Champ in-the-making
Champ in-the-making
Hi,

Sorry to bother you with a problem that, from what I've read in other threads in this forum, seems to be easy to solve. Unfortunately, all the code snippets won't work for me. All I am trying to do is, in an extended version of the Review & Approve workflow, to copy the documents attached to the workflow to a backup folder when the request is rejected.

My code:

<transition name="reject" to="rejected">
        <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
           <script>
              var myRoot=bpm_context.parent; // a workaround for the missing company_home root object
              var myUserhome=initiator.properties['cm:homeFolder'];
              var archiveFolder = myRoot.childByNamePath("Arbeitsbereich/Personal/Personalanforderungen/Abgelehnt");
                  for (var i = 0; i &lt; bpm_package.children.length; i++) {
                     bpm_package.children[i].copy(archiveFolder);
                  }
           </script>
         </action>
        </transition>

It won't work with the admin user as initiator and assignee of the tasks as well, so I guess it's not a problem with permissions. I've tried different folders as well, e.g. user's home directory. I am not even getting an error message, it is just not copying (or moving, as I've replaced the copy statement with move) the file which is a simple word doc.

Maybe I'm just too stupid… Hope somebody can help!

Thanks, Dennis
2 REPLIES 2

grimme
Champ in-the-making
Champ in-the-making
Hi Dennis,

I've noticed that Alfresco stops executing javascripts in workflows as soon as it encounters a blanco line or comments.
When you put logging statements before and after each line, you will notice that only your first line is being executed and all the rest is neglected.
Remove the comments from your script and you will at least get some action or error message.

Good luck,


Grimme

seshu
Champ in-the-making
Champ in-the-making
i tried with comments. It never stopped executing. (Edited : Use multi statement comment /*…*/.  seems // has problem. sorry for my earlier comment)

Seems your path is incorrect. bpm_context.parent won't take you to CompanyHome unless you are starting workflow from space under companyhome space