I can't transit a task with this error.


Hi all

I am a newbie at Bonita 7.2, I have a file field and it isn't required, but I can't transit to the next step with no file uploaded. Is it mandatory?
Can't I leave a file field empty?

"exception": "class org.bonitasoft.engine.bpm.contract.ContractViolationException", "message": "Error while validating expected inputs", "explanations": [ "null cannot be assigned to FILE"

Any assistance would be greatly appreciated.

Kind regards,

1 answer

This one is the BEST answer!


As of today I don't think there is a perfect solution. It seems that as long as a File is defined as a contract input, the engine expects to receive a JSON representation of that object, therefore any NULL or empty JSON object won't fulfill the contract requirement.

One way to make it works is to test on the client side if there is a File present in the upload widget.

Here is a snippet of code that show how to implement that:

if (Object.keys($data.formInput.input1).length !== 0) {
        return {
            'input1': $data.formInput.input1
    } else {
         console.log("No file provided");
        return {
            'input1': {'tempPath':null,'filename':null,'contentType':null}

Cheers Lio