generate document list in emails

1
0
-1

Hi,

In my process, I retrieve some documents provided by the user (List of documents) and I can generate 0 or several .docx files (Single Document).

At some point, I have to send an email with the provided and generated files. To do so, I created a script in the attach file part of the email connector :

import org.bonitasoft.engine.bpm.document.Document
ArrayList docs = list_of_documents_given_by_user;
if( docGenerated0 != null && docGenerated0.contentFileName != null ) docs += docGenerated0;
if( docGenerated1 != null && docGenerated1.contentFileName != null ) docs += docGenerated1; 
// ...
return docs;

Unfortunately, The email contains only the docGeneratedX files and not the list_of_documents_given_by_user, although in the log I get the mention of all the correct attachments ( for example, 2 files in the list_of_documents_given_by_user and 1 file docGenerated0 ).

DocumentImpl{id=2935, processInstanceId=18009, name='list_of_documents_given_by_user', author=101, creationDate=Tue Mar 02 14:19:27 HST 2021, hasContent=true, fileName='04_montageProjetCablage.txt', contentMimeType='text/plain', contentStorageId='3335', url='documentDownload?fileName=04_montageProjetCablage.txt&contentStorageId=3335', description='ajout', version='1', index=0}
DocumentImpl{id=2936, processInstanceId=18009, name='list_of_documents_given_by_user', author=101, creationDate=Tue Mar 02 14:19:31 HST 2021, hasContent=true, fileName='04_montageProjetGC.txt', contentMimeType='text/plain', contentStorageId='3336', url='documentDownload?fileName=04_montageProjetGC.txt&contentStorageId=3336', description='ajout', version='1', index=1}
DocumentImpl{id=2937, processInstanceId=18009, name='docGenerated0', author=-1, creationDate=Tue Mar 02 14:20:41 HST 2021, hasContent=true, fileName='demandeAutorisationDEQCablage.docx', contentMimeType='application/octet-stream', contentStorageId='3337', url='documentDownload?fileName=demandeAutorisationDEQCablage.docx&contentStorageId=3337', description='null', version='1', index=-1}

I also tried to loop through the files in list_of_documents_given_by_user in order to add them to the list docs which is returned, but the result is the same.

Any ideas?

Best,

Comments

Submitted by Dibyajit.Roy on Wed, 03/03/2021 - 12:22

import org.bonitasoft.engine.bpm.document.Document;
import org.bonitasoft.engine.bpm.document.DocumentValue;
import org.bonitasoft.engine.bpm.contract.FileInputValue;
import javax.activation.MimetypesFileTypeMap;
import java.util.logging.Logger;

List na = new ArrayList();
List nu = new ArrayList();

List fnames = [ ];
List documentsMerged = new ArrayList();
DocumentValue dv;
vbs_qnbn_Firm_Feasibility_Document.each { pj -> // pj is a java.util.Map }
Integer documentId = pj.getId();
dv = new DocumentValue( documentId );
documentsMerged.add(dv); }
attachedDocs.each { pj -> // pj is a FileInputValue}
dv = new DocumentValue( pj.getContent(), null, pj.getFileName() );
documentsMerged.add(dv); }

return documentsMerged;

Submitted by torea_1402565 on Mon, 03/08/2021 - 23:54

Thank you but I get errors in the log when using both ways to create the DocumentValue

No answers yet.
Notifications