How do I pass a document to a sub-process

1
0
-1

I have a process that uses a document as an input for a REST connector.
The document is initialized from a file upload in an instantiation form.

Now I want to call this process as a call activity from another process.
How do I pass the document from the main process to the called sub-process ?

When I use a contract and my document assigned to contract input, I get : DocumentImpl{...} cannot be assigned to FILE.

1 answer

1
+1
-1

Hi,

you can find the answer in the documentation ;)

HTH

Romain

Comments

Submitted by cjundt_1868075 on Thu, 06/18/2020 - 16:05

I did as stated in documentation but I get an exception :

"Declared return type interface org.bonitasoft.engine.bpm.document.Document is not compatible with evaluated type class org.bonitasoft.engine.bpm.document.DocumentValue for expression docEntree"

Submitted by romain.bioteau on Thu, 06/18/2020 - 16:23
import org.bonitasoft.engine.bpm.document.Document;
import org.bonitasoft.engine.bpm.document.DocumentValue;

def doc = apiAccessor.getProcessAPI().getDocument(subDocId)
new DocumentValue(apiAccessor.getProcessAPI().getDocumentContent(doc.getContentStorageId()), doc.getContentMimeType(), doc.getContentFileName()

The return type of the script must be org.bonitasoft.engine.bpm.document.DocumentValue The operation operator must be Document value

Submitted by cjundt_1868075 on Fri, 06/19/2020 - 11:09

Finally, I moved my code to a groovy scripting connector and it's working now.

Previously I had a task with no connectors at all and the code in an document assignment operation.
I think there may be a bug in case of a task having operations only (no connectors).

Thanks for your time

Submitted by romain.bioteau on Fri, 06/19/2020 - 11:11

I tried using operation only before posting and there was no issue. What version are you using ?

Submitted by cjundt_1868075 on Fri, 06/19/2020 - 11:20

7.10.5

But the way, is there a way to get a 7.11 beta build?
I'm not a java developer and I don't have the environment to build it by my own.

Submitted by romain.bioteau on Fri, 06/19/2020 - 11:36
Submitted by cjundt_1868075 on Fri, 06/19/2020 - 12:00

Great news, thank you.

Submitted by awnz on Tue, 07/12/2022 - 03:06

I think some bug may still be around with v2022.1. I've just hit the same thing with a process step that I have *not* changed for over a week, which was working up until today.

Trying to work out what triggered it, no luck so far. Why is Bonita suddenly telling me I've declared the return type to be Document when I've clearly set it to DocumentValue?


2022-07-12T11:45:25,431+1200 | bonita-test | WARN  | [Bonita-Worker-1-09|658] o.b.e.w.RetryingWorkExecutorService - THREAD_ID=658 | HOSTNAME=bonita-test | TENANT_ID=1 | Work ExecuteFlowNodeWork: flowNodeInstanceId: 365934 (37, false, false, false) failed. The element will be marked as failed. Exception is: org.bonitasoft.engine.expression.exception.SExpressionEvaluationException: FLOW_NODE_INSTANCE_ID=365934 | Declared return type interface org.bonitasoft.engine.bpm.document.Document is not compatible with evaluated type class org.bonitasoft.engine.bpm.document.DocumentValue for expression docWorkOrderMR
        wrapped by org.bonitasoft.engine.core.operation.exception.SOperationExecutionException: org.bonitasoft.engine.expression.exception.SExpressionEvaluationException: FLOW_NODE_INSTANCE_ID=365934 | Declared return type interface org.bonitasoft.engine.bpm.document.Document is not compatible with evaluated type class org.bonitasoft.engine.bpm.document.DocumentValue for expression docWorkOrderMR

From the process file:

<operations xmi:type="expression:Operation" xmi:id="_d9Jl8NZeEeytyd0QaEjacA">
            <leftOperand xmi:type="expression:Expression" xmi:id="_d9Jl8dZeEeytyd0QaEjacA" name="docWorkOrderMR" content="docWorkOrderMR" type="DOCUMENT_REF_TYPE">
              <referencedElements xmi:type="process:Document" xmi:id="_pdp0sNZeEeytyd0QaEjacA" name="docWorkOrderMR"/>
            </leftOperand>
            <rightOperand xmi:type="expression:Expression" xmi:id="_d9Jl8tZeEeytyd0QaEjacA" name="copyEmailedDataFile()" content="import org.bonitasoft.engine.bpm.document.Document;
import org.bonitasoft.engine.bpm.document.DocumentValue;

// Retrieve the Work Order document from the email retrieval process

if (emailedDataFileID) {
	Document doc = apiAccessor.getProcessAPI().getDocument(emailedDataFileID)
	new DocumentValue(apiAccessor.getProcessAPI().getDocumentContent(doc.getContentStorageId()), doc.getContentMimeType(), doc.getContentFileName())
}" interpreter="GROOVY" type="TYPE_READ_ONLY_SCRIPT" returnType="org.bonitasoft.engine.bpm.document.DocumentValue">
              <referencedElements xmi:type="process:Data" xmi:id="_C1tpINZfEeytyd0QaEjacA" name="emailedDataFileID" dataType="_zbtdL8qcEeyMzPR3BeZevA"/>
              <referencedElements xmi:type="expression:Expression" xmi:id="_C1tpIdZfEeytyd0QaEjacA" name="apiAccessor" content="apiAccessor" type="TYPE_ENGINE_CONSTANT" returnType="org.bonitasoft.engine.api.APIAccessor"/>
            </rightOperand>
            <operator xmi:type="expression:Operator" xmi:id="_d9Jl89ZeEeytyd0QaEjacA" type="DOCUMENT_CREATE_UPDATE"/>
          </operations>

I've similarly used a Groovy script as a workaround, using apiAccessor.getProcessAPI().attachDocument.

Submitted by romain.bioteau on Tue, 07/12/2022 - 08:59

Hi, Can you sharea .bos file reproducing your please ? You can open a ticket in the bugtracker.

Thanks for your help.
Romain

Submitted by awnz on Tue, 07/12/2022 - 10:13

Thanks, I'll try to get to making something reproducible in the next week or two, as I'm swamped with testing and training on this project, and for now have my workaround. Still don't know why the behavior changed a couple of weeks after I wrote this bit, but my guess is that it may be difficult to reproduce.

Notifications