cancel
Showing results for 
Search instead for 
Did you mean: 

Moving document without creating tasks

e-no91
Champ in-the-making
Champ in-the-making
I'm thinking about making an advanced workflow that directly moves a file from folder to folder without initiating any task.
I've tried deleting everything I think is related to task until my processdefinition.xml is left as such:

<?xml version="1.0" encoding="UTF-8"?><process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="wfl:lifecycleapproval">            <action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">                <!– Apply the Workflow Lifecycle Aspect (wfl:status) if not set already. Note: The default wfl:status property is draft –><runas>admin</runas>                <script>                    var dest = companyhome.childByNamePath(bpm_moveDestination);for (var i = 0 ; i &lt; bpm_package.children.length; i++){bpm_package.children.move(dest);}                </script>            </action>     </process-definition>‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍


But when I call this workflow through js, it still runs as a task.

My question is, is it actually possible to use a workflow to do file movement without starting a task?

Thanks in advance!
4 REPLIES 4

jpotts
World-Class Innovator
World-Class Innovator
Have you tried creating a sequence flow between start and end and then adding your script as an execution listener on the sequence flow?

    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="endevent1">      <extensionElements>        <activiti:executionListener event="start" class="org.alfresco.repo.workflow.activiti.listener.ScriptExecutionListener">          <activiti:field name="script">            <activiti:string><![CDATA[logger.log("Hello, World!");]]></activiti:string>          </activiti:field>        </activiti:executionListener>      </extensionElements>    </sequenceFlow>‍‍‍‍‍‍‍‍‍‍‍


Jeff

e-no91
Champ in-the-making
Champ in-the-making
Hi Jeff,

I've tried that and the workflow still sends user a task, without moving the document.

My processdefinition is still the same,

Here is my current code for lifecycle-process.bpmn20.xml
<?xml version="1.0" encoding="UTF-8" ?><definitions id="lifecycle-definitions"             typeLanguage="http://www.w3.org/2001/XMLSchema"             expressionLanguage="http://www.w3.org/1999/XPath"             targetNamespace="http://activiti.org/bpmn20"              xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"             xmlns:activiti="http://activiti.org/bpmn">    <process id="activitiLifecycleApproval" name="Activiti Lifecycle Process">       <extensionElements>           <!– When process is deleted/cancelled, status should be set to draft –>             <activiti:executionListener event="end" class="org.alfresco.repo.workflow.activiti.listener.ScriptExecutionListener">              <activiti:field name="script">                                     </activiti:field>            </activiti:executionListener>         </extensionElements>        <startEvent id="startE"/>        <sequenceFlow id='flow1'             sourceRef='startE'            targetRef='end'>             <extensionElements>                <activiti:executionListener event="start" class="org.alfresco.repo.workflow.activiti.listener.ScriptExecutionListener">          <activiti:field name="script">            <activiti:string><runas>admin</runas> var dest = companyhome.childByNamePath(bpm_moveDestination);for (var i = 0 ; i &lt; bpm_package.children.length; i++){bpm_package.children.move(dest);}</activiti:string>          </activiti:field>        </activiti:executionListener>            </extensionElements>        </sequenceFlow>              <endEvent id="end" />    </process></definitions>‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍






and my js
var workflow = actions.create("start-workflow");workflow.parameters.workflowName = "jbpm$wfl:lifecycleapproval";workflow.parameters["bpm:assignee"] = "us1";workflow.parameters["bpm:moveDestination"] = "Sites/ar-rahnu/documentLibrary/SEMAKAN";workflow.execute(document);‍‍‍‍‍‍‍


I wonder if it is possible to have assignee to auto approve a task directly from the xml? So that the task is sent and completed at the same time..

I have another question, if I call "jbpm$wfl:lifecycleapproval" in js, it will refer to processdefinition.xml, and if I call "activiti$activitiLifecycleApproval" it refers to the bpmn20 file? Or both? I'm a bit confused after playing around with the files..

kaynezhang
World-Class Innovator
World-Class Innovator
You have made several mistakes:
1.Your workflow engine is activiti ,sou workflow name should be
activiti$activitiLifecycleApproval‍
,you are using
jbpm$wfl:lifecycleapproval‍
in your javascrit,so the above workflow might be not executed at all.
2.It seems
  </activiti:field>‍
in below code is no use (you didn't add  javascript into it) .Please delete the whole session.,otherwise it might cause error
       <extensionElements>           <!– When process is deleted/cancelled, status should be set to draft –>             <activiti:executionListener event="end" class="org.alfresco.repo.workflow.activiti.listener.ScriptExecutionListener">              <activiti:field name="script">                  </activiti:field>            </activiti:executionListener>‍‍‍‍‍‍‍‍

3. also you should define runas like this
            <activiti:executionListener event="start" class="org.alfresco.repo.workflow.activiti.listener.ScriptExecutionListener">               <activiti:field name="runAs"><activiti:string>admin</activiti:string></activiti:field>               <activiti:field name="script">                  <activiti:string>                        var dest = companyhome.childByNamePath(bpm_moveDestination);                        for (var i = 0 ; i &lt; bpm_package.children.length; i++){                           bpm_package.children.move(dest);                        }                  </activiti:string>               </activiti:field>            </activiti:executionListener>‍‍‍‍‍‍‍‍‍‍‍‍‍




If you call "jbpm$wfl:lifecycleapproval" in js,it will only refer to  a jbpm process defination who's id is "jbpm$wfl:lifecycleapproval"
A process name in alfresco includes two part ,the part before $ is engine name,the part after $ is process id you define in your process definition.

douglascrp
World-Class Innovator
World-Class Innovator
Is it possible to execute the javascript code using "System" user?
I tried, and it says the user system doesn't exist.