11-20-2016 05:17 AM
Nel mio workflow ho fatto sì che vi fossero 3 tipi di documenti allegati, 2 obbligati e una terza associazione che permette di allegare più documenti opzionali:
<aspect name="psw:allegabile">
<associations>
<association name="psw:docDRC">
<title>Domanda di Ricostruzione di Carriera</title>
<source>
<mandatory>true</mandatory>
<many>false</many>
</source>
<target>
<class>cm:content</class>
<mandatory>true</mandatory>
<many>false</many>
</target>
</association>
<association name="psw:docAS">
<title>Autocertificazione dei Servizi</title>
<source>
<mandatory>true</mandatory>
<many>false</many>
</source>
<target>
<class>cm:content</class>
<mandatory>true</mandatory>
<many>false</many>
</target>
</association>
<association name="psw:docAllegati">
<title>Documenti allegati</title>
<source>
<mandatory>false</mandatory>
<many>true</many>
</source>
<target>
<class>cm:content</class>
<mandatory>false</mandatory>
<many>true</many>
</target>
</association>
</associations>
</aspect>
I documenti devono essere spostati da una cartella all'altra, fatto che non crea problemi per psw:docDRC e psw:docAS (ho utilizzato la funzione move() di Javascript), tuttavia i documenti opzionali di psw:docAllegati generano un errore nel caso in cui non ve ne siano.
So che dovrei inserire un controllo if per verificare le l'array delle associazioni non sia vuoto, ma non riesco a capire in che modo, qualcuno saprebbe aiutarmi?
In allegato la descrizione del workflow e il modello
11-20-2016 06:08 AM
Forse ho trovato una soluzione, il problema è che mi segnala la mancanza di una parentesi dopo la condizione... e io non vedo nessuna parentesi mancante:
<sequenceFlow id="flow1" sourceRef="startevent1" targetRef="protocollaDRC">
<extensionElements>
<activiti:executionListener event="take" class="org.alfresco.repo.workflow.activiti.listener.ScriptExecutionListener">
<activiti:field name="script">
<activiti:string>
<![CDATA[
var gruppo = bpm_groupAssignee.properties["cm:authorityName"];
var dest = companyhome.childByNamePath("/"+gruppo);
psw_docDRC.move(dest);
psw_docAS.move(dest);
if (psw_docAllegati.children.length > 0){
for (var i = 0; i < psw_docAllegati.children.length; i++){
psw_docAllegati.children[i].move(dest);
}
}]]>
</activiti:string>
</activiti:field>
</activiti:executionListener>
</extensionElements>
</sequenceFlow>
<userTask id="approvaDRC" name="Approva Domanda di Ricostruzione di Carriera" activiti:formKey="psw:activitiApprovaDRC">
<extensionElements>
<activiti:taskListener event="complete" class="org.alfresco.repo.workflow.activiti.tasklistener.ScriptTaskListener">
<activiti:field name="script">
<activiti:string>
<![CDATA[if(task.getVariableLocal('psw_esitoValutazioneDRC') == 'Approvata'){
execution.setVariable('psw_proseguiDRC', true);
var dest = companyhome.childByNamePath("/Ragionerie dello Stato");
psw_docDRC.move(dest);
psw_docAS.move(dest);
if(psw_docAllegati.children.length > 0){
for(var i = 0; i < psw_docAllegati.children.length; i++ ){
psw_docAllegati.children[i].move(dest);
}
}
}else{
execution.setVariable('psw_proseguiDRC', false);
}]]>
</activiti:string>
</activiti:field>
<activiti:field name="runAs">
<activiti:string>admin</activiti:string>
</activiti:field>
</activiti:taskListener>
</extensionElements>
<humanPerformer>
<resourceAssignmentExpression>
<formalExpression>${bpm_assignee.properties.userName}</formalExpression>
</resourceAssignmentExpression>
</humanPerformer>
</userTask>
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.