Hello,
This question is in reference to and a follow-up of the query I had posted earlier on this link.
So I have a simple doc upload form that has a list of documents and an file upload widget with each.
In my contract, I have defined a variable of type file that accepts multiple objects → formDocuments.
In my UI designer I have a similar JSON that takes files that are uploaded through the form.
In order to retrieve the documents through the contract, I have written the following script:
import org.bonitasoft.engine.api.ProcessRuntimeAPI;
import java.util.logging.Logger;
int debugCount = 0;
boolean debug = true;
Logger logs = Logger.getLogger(“org.bonitasoft.myFirstRetailerForm”);
ProcessRuntimeAPI processRuntimeAPI = apiAccessor.getProcessAPI();
String processName = processRuntimeAPI.getProcessInstance(processInstanceId).getName();
logs.severe("Document list size : "+formDocuments.size());
List xList = new ArrayList();
def doc_aliases = [“site_verify”, “laf”];
int docCounter = 0;
for (def i = 0; i <formDocuments.size(); i++){
if (formDocuments[docCounter] != null){
// def doc_name = (formDocuments[docCounter][“fileName”]);
Long docId = apiAccessor.getProcessAPI().getLastDocument(processInstanceId, doc_aliases[i]).getId();
xList.add(docId);
}
docCounter = docCounter+1;
}
logs.severe(“List prepared!!”);
return xList;
Now when I run this task in debug mode through the studio, I am able to see that the contract is fulfilled but it throws an exception saying Groovy script throws an exception of type class org.bonitasoft.engine.bpm.document.DocumentNotFoundException with message = org.bonitasoft.engine.commons.exceptions.SObjectNotFoundException: Document not found
I can’t figure out where I am falling short as syntactically, we will retrieve the ID of the doc from the name of the document. But the way I am trying to access it, is not working.
Appreciate the help I can get in this regard!
Regards
Megha