workflowfilenamesalfrescobusiness-process

Change the file name Alfresco


I need to change the name of the file attached to the workflow and move to another location during the execution. The file name is generated based on the information entered in the form of process (Registration Number field and Sender). How can this be implemented? Thanks!

For example: BX-2/Nick_Berry.xls

Screen


Solution

  • I am find own solution this issue. Need to create execution listener in user task. Its code is:

    <extensionElements>
                        <activiti:executionListener class="org.alfresco.repo.workflow.activiti.listener.ScriptExecutionListener" event="start">
                            <activiti:field name="script">
                                <activiti:string><![CDATA[    
    
                                   if (typeof execution.getVariableLocal('zvernennya_registrationnumber') != undefined) execution.setVariable('zvernennya_registrationnumber', execution.getVariableLocal('zvernennya_registrationnumber'));    
                                   if (typeof execution.getVariableLocal('zvernennya_sender') != undefined) execution.setVariable('zvernennya_sender', execution.getVariableLocal('zvernennya_sender'));        
                                     for (var i = 0; i < bpm_package.children.length; i++) {
                                        var child = bpm_package.children[i];   
                                            a = child.properties['cm:name'].split('.'); 
                                            var ext = a[a.length-1];   
    
                                            child.properties['cm:name']=zvernennya_registrationnumber+" "+zvernennya_sender+"."+ext;                  
                                            child.save();
                                    }
                                ]]></activiti:string>
                            </activiti:field>
                        </activiti:executionListener>
                </extensionElements>