Thank you Pierre-Yves, very insightful comments.
The early completion scenario won’t work here because we could have x different tasks created, but the initial approver may only be able to only work one or two of these. I got this to MOSTLY work using a separate process call for the multiinstantiated attributes. My problem NOW is that I cannot fetch the user-uploaded documents from the subprocess and move them into the parent process. I’m thinking this is a bug that I cannot work around.
When I have the following code on as an Operation to set the process’s documents, it outputs 0 results for both Open & Archived documents – but, if I execute this as another step after the multi-instantiated Call activity it will return the Archived documents I want — but I lose the submitter which is less than ideal. It’s too bad the Call activity doesn’t support sending/receiving Documents (I’m about to try setting the documents to a List pool variable in the subprocess and retrieve the data that way…)
import java.util.logging.Logger
import org.bonitasoft.engine.api.DocumentAPI
import org.bonitasoft.engine.bpm.document.ArchivedDocument
import org.bonitasoft.engine.bpm.document.ArchivedDocumentsSearchDescriptor
import org.bonitasoft.engine.bpm.document.Document
import org.bonitasoft.engine.bpm.document.DocumentValue
import org.bonitasoft.engine.bpm.document.DocumentsSearchDescriptor
import org.bonitasoft.engine.search.SearchOptionsBuilder
import org.bonitasoft.engine.search.SearchResult
Logger logger = Logger.getLogger(“org.bonitasoft”);
def processAPI = apiAccessor.getProcessAPI()
List newDocValues = new ArrayList();
List newDocs = new ArrayList();
logger.info(“Look for OPEN Documents in Case #”+subCaseId.toString());
SearchOptionsBuilder sob = new SearchOptionsBuilder(0, 100);
sob.filter(DocumentsSearchDescriptor.PROCESSINSTANCE_ID,subCaseId);
List documents = processAPI.searchDocuments(sob.done()).getResult();
logger.info(“Got “+documents.size().toString()+” documents to process!”);
for(Document doc : documents) {
newDocs.add(doc);
logger.info(doc.toString());
DocumentAPI docAPI = processAPI;
def docContent = processAPI.getDocumentContent(doc.contentStorageId)
DocumentValue dv = new DocumentValue(docContent,doc.getContentMimeType(), doc.getContentFileName())
newDocValues.add(dv);
}
logger.info(“Look for ARCHIVED Documents in Case #”+subCaseId.toString());
sob = new SearchOptionsBuilder(0, 100);
sob.filter(ArchivedDocumentsSearchDescriptor.PROCESSINSTANCE_ID,subCaseId);
List archDocuments = processAPI.searchArchivedDocuments(sob.done()).getResult();
logger.info(“Got “+archDocuments.size().toString()+” documents to process!”);
for(ArchivedDocument doc : archDocuments) {
newDocs.add(doc);
logger.info(doc.toString());
DocumentAPI docAPI = processAPI;
def docContent = processAPI.getDocumentContent(doc.contentStorageId)
DocumentValue dv = new DocumentValue(docContent,doc.getContentMimeType(), doc.getContentFileName())
newDocValues.add(dv);
}
return newDocs;
As for the subprocess that handles the rest api call, the “login to api” step simply fetches the security token and parses it for the “Execute” step to use – i’m guessing this would be safe even in a clustered environment (which it isn’t)
Thanks!