Attach File

I assign the attachment to a process variable, I have read that a document is created in the pool, but when I do the assignment in the option data widget shows me the following error: “expression document type is not supported”

Hi,

You cannot assign an attachment to a process variable. You need to use a document data instead of a variable data (it’s in a different section below the variable section when you are designing your process).
You will then be able to select this document as output of the file widget in your form.

The documentation on the file widget is not very clear. I’ve figured this out after hours playing with it.

The problem you are having is because you have the wrong assignment type. For a file widget, you must use “Set document” to assign its value to a Document.

(Click on the file widget, go to General/Data. I assume right now, since you’re having problems, the blue assignment link connecting the file widget and your Document data says, “Takes value of”. Click on it, and change it to “Set document”)

Hope this helps.
-Bao

P.s: This is not related but since Anthony is watching this post, I have a quick question for Anthony. Knowing that you’re very knowledgeable Bonita developer, is there away to remove an attachment from a process (after attaching it to the process using ProcessAPI.attachDocument())in Bonita 6.x?

Thank you

That was precisely what I did, create a document but when I assign the output widget shows me an error

Did you use a file widget ? Only file widgets can be used to set the value of a document.

Hi,
Thanks for your comments about document management in Bonita and the lack of clear documentation about it.
We are planning a review and update of this in the near future.
Stay tuned…

Hi,

Indeed, the type of the action to perform is different for a document from what it is for a variable.

Currently there is no method to remove an attachment from a process once it has been added. The only thing you can do is adding a new version document with a null value.

Thanks for responding Anthony.

Our application deals with a lot of attachments. We have our own attachment management scheme. so the attachments saved in Bonita database is not really needed. We just want to clear them out to free the memory.

I’m thinking of directly manipulate the content of the document (blob) in the ‘document_content’ table in Bonita database (replacing it with 1 byte of data).

What do you think?

Thanks,
-Bao

Thanks for responding Anthony.

Our application deals with a lot of attachments. We have our own attachment management scheme. so the attachments saved in Bonita database is not really needed. We just want to clear them out to free the memory.

I’m thinking of directly manipulate the content of the document (blob) in the ‘document_content’ table in Bonita database (replacing it with 1 byte of data).

What do you think?

Thanks,
-Bao

I would advise against that. We discourage anyone from any direct modification of the database. If you really need to do that, I think a better way would be to write a process connector that uses our DocumentService to remove the document content.

I’ve searched the Bonita Javadoc but couldn’t find DocumentService API. Would you point me to where the document is.

Thanks,
-Bao