Document not accessible in "Overview" but available in Mail connector

1
0
-1

Hello,

in my app I attach correctly a document with a groovy connector:

....

processAPI.attachDocument(processInstanceId, "documentXYZ", doc.name, "application/pdf", doc.bytes);

....

Then I send it with an e-mail connector as an attachment, but If I try to open it in case Overview I get the error "500 Internal Server Error. Oops. Error.". In the logfile I've: "org.bonitasoft.forms.server.DocumentImageServlet Error while retrieving the document with ID xxxxxx from the engine."

It seems that the document ID in the url is not correct.

In addition, the documents are accessible (the document ID in the url is correct) in case Overview when the case is open, but when the case is closed they change the id and are not accessible in case Overview (the url ID are not correct).

Any suggestions?

Thank you!

1 answer

1
0
-1
This one is the BEST answer!

Hi,

When a case is closed, the case is archived, and so are its documents.
You have to retrieve those archive documents using all the archived API methods from the process API.

For example (can't find the way to render correctly code blocks sry ...):




import org.bonitasoft.engine.bpm.document.ArchivedDocumentsSearchDescripto
import org.bonitasoft.engine.bpm.process.ArchivedProcessInstance
import org.bonitasoft.engine.search.Order
import org.bonitasoft.engine.search.SearchOptionsBuilder
import com.bonitasoft.engine.api.ProcessAPI
import com.bonitasoft.engine.bpm.flownode.ArchivedProcessInstancesSearchDescriptor


def retrieveDocuments(ProcessAPI processAPI, long archivedCaseId) {

def archivedInstance = retrieveArchivedInstance(processAPI, archivedCaseId)

return processAPI.searchArchivedDocuments(new SearchOptionsBuilder(0, Integer.MAX_VALUE).with {

filter(ArchivedDocumentsSearchDescriptor.PROCESSINSTANCE_ID, archivedInstance.sourceObjectId)

sort(ArchivedDocumentsSearchDescriptor.DOCUMENT_CREATIONDATE, Order.DESC)

done()

}).getResult()

}

def ArchivedProcessInstance retrieveArchivedInstance(ProcessAPI processAPI, long caseId) {

def options = new SearchOptionsBuilder(0, 1)

.filter(ArchivedProcessInstancesSearchDescriptor.ID, caseId)

. done()

def results = processAPI.searchArchivedProcessInstances(options).getResult()

if (results.isEmpty()) {

// error

}

return results[0]

}

Comments

Submitted by mario.diture on Wed, 03/11/2020 - 11:10

Hello Adrien, I will keep your suggestions in mind.

However the hassle is that users click on closed cases "Overview" and try to show the documents.

In the meantime in documentation I'll highlight that the documents are archived in closed cases.

Thank you!

Submitted by adrien.lachambre on Wed, 03/11/2020 - 11:16

May I know your Bonita version and if you use the default case overview or a custom one? I sem to recall that we had some issues with the default case overview in previous Bonita versions.

Submitted by mario.diture on Wed, 03/11/2020 - 11:24

Yes, the version is Bonita 7.9 and we use the default case overview

Submitted by adrien.lachambre on Wed, 03/11/2020 - 14:16

The case overview looks fine on Bonita 7.9.4, i'm able to retrieve archived documents.

Here is the documentation about how to handle documents through Java api's, you may want to check if your implementation is correct (even if what you described in your first message looks fine): https://documentation.bonitasoft.com/bonita/7.9/handling-documents
An other possibility would be that the archiving of the documents fails for some reasons.
You could try to retrieve all the archived documents for a case (in a small groovy script) to see what is really archived.

Submitted by mario.diture on Wed, 03/11/2020 - 17:40

Ok, thank you

Notifications