cancel
Showing results for 
Search instead for 
Did you mean: 

Move files workflow

msvoren
Champ in-the-making
Champ in-the-making
Hi.
I need to create workflow which will be initiated with rules. Workflow simply needs to move document to another folder. I need little help. Here is what I have so far:

MODEL:

<model name="owf:MoveData" xmlns="http://www.alfresco.org/model/dictionary/1.0">
<imports>
   <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
   <import uri="http://www.alfresco.org/model/bpm/1.0" prefix="bpm"/>
   <import uri="www.alfresco.org/model/workflow/1.0" prefix="wf" />
   <import uri="www.alfresco.org/model/content/1.0" prefix="cm" />
</imports>

<namespaces>    <namespace uri="oawf" prefix="owf"/> </namespaces>

<types>
   <type name="owf:startMove">
      <parent>bpm:startTask</parent>
   <properties>
           <property name="owf:whereTo">
      <title>Destination</title>
      <type>d:text</type>
           </property>
        </properties>
   </type>
</types>
</model>

PROCESS DEF:

<process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="owf:moveFiles">
   <swimlane name="initiator"/>
   <start-state name="start">
      <task name="owf:startMove" swimlane="initiator"/>
      <transition name="" to="end">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
      <runas>admin</runas>
           <script>
      var dest = companyhome.childByNamePath("Dest");
      document.move(dest);
           </script>
         </action>
      </transition>
   </start-state>
<end-state name="end"/>
</process-definition>


Rule script which i execute when file comes to folder:

          var workflow = actions.create("start-workflow");
          workflow.parameters.workflowName = "jbpm$owf:moveFiles"; 
          workflow.execute(document);

When executed, i get:

org.alfresco.scripts.ScriptException: Failed to execute script 'workspace://SpacesStore/a8a9950c-939c-11dd-9e2e-5be0a253008d': Failed to execute script 'workspace://SpacesStore/a8a9950c-939c-11dd-9e2e-5be0a253008d': Wrapped org.springframework.orm.hibernate3.HibernateSystemException: null index column for collection: org.jbpm.graph.def.ProcessDefinition.definitions; nested exception is org.hibernate.HibernateException: null index column for collection: org.jbpm.graph.def.ProcessDefinition.definitions (AlfrescoScript#3)
What am I doing wrong? Thanks
4 REPLIES 4

msvoren
Champ in-the-making
Champ in-the-making
Solved problem from up there.. But still, i run this workflow, but script is not executed.. This should run and create/move/copy file, then end workflow..
What's wrong? Anybody?

<process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="cust:copyFiles">
 
   <start-state name="start">
     
      <transition name="" to="end">
         <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
      <runas>admin</runas>
           <script>
      var dest = companyhome.childByNamePath("Reports");
      var file = dest.createFile("itWorks.html");
      file.save();
           </script>
         </action>
      </transition>
   </start-state>

<end-state name="end"/>
</process-definition>

skirjak
Champ in-the-making
Champ in-the-making
try this

<script>
    <variable name="companyhome" access="read" />
    <expression>
         var dest = companyhome.childByNamePath("Reports");
         var file = dest.createFile("itWorks.html");
    </expression>
</script>

algoworks
Champ in-the-making
Champ in-the-making
And it might be silly, but you please make sure that "Reports" folder does exist in your company home  Smiley Very Happy otherwise it will throw an error before creating the file.

Thanks,
Algoworks Alfresco Team
http://www.algoworks.com

msvoren
Champ in-the-making
Champ in-the-making
It worked at the end.. Could be I had some comments in script part of workflowprocess..
I realized script is not parsed with breaks (enters), so, if you put comments on the first line of your script, alfresco will recognize whole script as 1 line, which would be in comment in this case..

e.g.
<script>
//comment
do.something();
</script>

Alfresco reads this as:
//comment do.something();

:lol: