OK, I’m back.
Here is the way I would do it…sorry if it takes a step back a bit. That’s the way I work
Process A - get the files
Process A add a list variable “filesForAlfresco”
Step1 Form Load the files (as previously discussed)
Step1 - NOT of the Form, NOT on the Submit Button, but ON the STEP itself as an OPERATION (in the process diagram highlight the Step only) add the following code to a Script Connector:
List xList = new ArrayList();
def x;
if (inputDoc01==null){ /* do nothing / } else{x = apiAccessor.getProcessAPI().getLastDocument(processInstanceId, “inputDoc01”).getId(); xList.add(x);}
if (inputDoc02==null){ / do nothing / } else{x = apiAccessor.getProcessAPI().getLastDocument(processInstanceId, “inputDoc02”).getId(); xList.add(x);}
if (inputDoc03==null){ / do nothing */ } else{x = apiAccessor.getProcessAPI().getLastDocument(processInstanceId, “inputDoc03”).getId(); xList.add(x);}
etc…
return xList;
This creates a list of the document id’s of the documents in the process that have been uploaded. That’s all you need.
In the Operation Left hand “filesForAlfresco” Takes the value of the above script.
In Step2 (the iterative step)
Input List = “filesForAlfresco”;
Iterator = docID of type java.lang.long;
Map the docID to the docID of the subprocess
This will execute the subprocess for each found input document in the “filesForAlfresco” list.
In the subprocess:
You will have a variable docID of type long
and a Document, ONLY ONE, that’s all that’s needed.
Step1 has a script connector (from http://documentation.bonitasoft.com/documents )
import org.bonitasoft.engine.bpm.document.Document;
import org.bonitasoft.engine.bpm.document.DocumentValue;
Document doc=apiAccessor.getProcessAPI().getDocument(sub_docId);
DocumentValue docValue=new DocumentValue(apiAccessor.getProcessAPI().getDocumentContent(doc.getContentStorageId()), doc.getContentMimeType(), doc.getContentFileName());
return docValue;
The return from the connector should be assigned to the Document Variable in the subprocess. NOTE - Change the operator to SET Document, that is not Takes the value of
You now have a document in the subprocess that you can use in Step 2, the Alfresco connector.
That’s it, can’t help any more. It will work I’m sure of it. It’s the way I’m doing mine (well almost )
regards
Seán