How to write on database at the end of a process? [SOLVED]


Hi, I am using Bonita BPM and i developed an API extension. I also added a postgres db storing business data (products and so), leaving to Bonita the process handling.
My environment involves two processes:
- the main process
- a subprocess

My issue is the following:
what's the right way to trigger an update to my database each time the subprocess instance is completed? I would like to, say, change the state of the product involved in the subprocess.

From the documentation, I can't get whether I should make use of a connector or a event handler, or something else.

Thank you for your help


Submitted by antoine.mottier on Fri, 01/29/2016 - 10:19

If your "product" is stored using Bonita BPM Business Data feature the way to go is to define a service task at the end of the sub process and on the service task define an operation.

If you use an external database (not managed by Business Data) I suggest to use a database connector as recommended by Sean. Use the data source connector with a connection pool configuration to ensure performance.

Submitted by davide.abati on Fri, 01/29/2016 - 10:29

Thank you antoine, I think a database connector is the win. I have now the issue of customizing my query based on the process variables. I explained it better answering Sean

1 answer

This one is the BEST answer!

I always use a connector. much easier...


PS: If this reply answers your question, please mark a resolved.


Submitted by davide.abati on Fri, 01/29/2016 - 10:27

Thank you Sean. I'm configuring the connector out for the final subprocess activity right now. How can i use the subprocess variables to customize my query? Let's say i have a process variable "product_id" and i want to update the record like "UPDATE products SET state='completed' WHERE product_id = (%product_id)".

Submitted by Sean McP on Fri, 01/29/2016 - 11:58

I think your statement should be:

UPDATE products SET state='completed' WHERE product_id = {$product_id}

this will do the substitution,

Or to save doing a single call per subprocess you could do something like as shown here using a script connector:


Submitted by davide.abati on Fri, 01/29/2016 - 12:15

Thank you, it worked!