cancel
Showing results for 
Search instead for 
Did you mean: 

Copy Documents within a review Workflow

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

I' m completly new to Alfresco. I have a problem with javascript, which copies the documents within the review workflow to homespaces of specific users.
The target persons are in an association of the custom content model which will be set by content rules. The model is valid and can be used.

I've tried to create a JavaScript to implement this copy mechnism to the specific home dirs. But it did not work.
Here is the code I've tried (with a static username):

copier.js

var personNodeRef = personService.getPerson(admin);
NodeRef homespaceNodeRef = (NodeRef) nodeService.getProperty(personNodeRef, ContentModel.PROP_HOMEFOLDER);
NodeRef localeNoderef = document.getnodeRef;
filefolderservice.copy(localeNoderef,homespaceNoderef, "test");
copy.save();

Additionally I would like to implement 2 more things:
* The target person is saved within a association called mySmiley Tongueerson, which the reviewer has to set - How can I read (through the array) every usernames.
* I would like to add theses script to the out-of-the-box review Workflow. I think the right transistion would be the last one:

review_processdefinition.xml
 
  <task name="wf:approvedTask" swimlane="initiator" />
                <transition name="" to="end">
                         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
                                <script>
                                      // it should be here?
                                </script>
                         </action>
                </transition>
        </task-node>

———————————-
Facts to the environment:
Version Alfresco: Alfresco 3.3
OS: Ubuntu 10.04 Lucid Lynx
DB: MySQL
———————————-

Can you help me?
1 REPLY 1

zladuric
Champ on-the-rise
Champ on-the-rise
Well, here's how I copy documents in my workflows, hope it helps:

The workflow transition imports the javascript file containing all the logic and calls the correct function, passing the file and anything else as parameters:

   <transition to="model:sometasknode" name="SomeAction">
               <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
         <runas>admin</runas>
         <script>
            &lt;import resource="classpath:alfresco/extension/workflows/MyCustomWorkflowLogic.js"&gt;
            myCustomFunction(bpm_package.children[0], "FolderName");
         </script>
            </action>
   </transition>

Then, in the custom logic file, I do the copying and moving around, ie:

function myCustomFunction( doc, parameter) {
   var destination = companyhome.childByNamePath("Sites/somesite/documentLibrary/");
   var destination2 = userhome..childByNamePath(parameter);
   doc.copy(destination);
   doc.copy(destination2);
   doc.properties["some:prop"]="A detail here";
   // whatever else, ie. mail a person or whatever.
}

I hope this helps.