Iam newbiee to camunda , I haven’t done much analysis but feel to ask some questions regarding data persistence. I have used JBPM for a while , it has a data modeller in which user can create objects of our own type and facility to persist in database . Say i have an object person having name, age , addresses attributes. which is binded to task forms. Once the process starts the user provided data will be persisted in person table.
Hi @Ajr
No equivalent data modeler in camunda.
You could handle it in many ways
In case you are using embedded forms then one easy way is to use Json Variables as in below links
Have you considered using DMN tables for persistence? That may be a very ignorant question, but I know you can store information in them that can be extracted based upon certain criteria. This is a very simple form of what JBPM decision support provides, but might help.
From my understanding DMN tables are kind of rules table which are used as a decision point in workflow. My requirement is some what different from that . I want data given in the form to be persisted in my own tables.
You are correct about the DMN tables. Perhaps I’m oversimplifying your requirements, but it sounds like you want to take data from a form and store it in a database. To do that, you would need use a script (JavaScript or Groovy) or write some Java code that would take these variables and store them in a database.
Conceptually, you would put the form input into process variables. For example, if your form had an account number field, you would use something like this in JavaScript:
Then, you would execute code to put that data into the database. I’m sorry, but I haven’t actually done this. However, I would use a Java class. It would need to contain something like this:
The URL below has a simple example of how to perform the insert into MySQL. The key here is understanding how you can set the process variable with form data and then retrieve that data so that you can insert it into a database.
Thanks for your reply. My requirement is little bit complex. I have a request form for getting approval for purchasing some items. In the user task form , user provide a list of items they want to purchase . So i need to hold all these element as a list. How can i persist these to a database with help of camunda.
Within Camunda, you could use a Listener to execute the database inserts. In the workflow you can use a Listener to execute code before or after a task. In the case of the example I provided, you might be use an “Event end” Listener. When defining the Listener, you would set the “Listener Type” to “Java Class”. In the “Java Class” box, you would put the name of the Java class you created to perform the insert (example: com.ajr.StoreOrderForm). This class would need to made available within whatever Java container you are running Camunda.
You would create a table in the database that contains a column with a unique ID (example: the session ID) and columns for each line item of the order form (example: part number, quantity, cost, etc.). Once you retrieve the data from the list, you would insert records into the database using the unique ID column as the key. When you want to retrieve that particular order, you would select rows from the table that matched the unique ID.
This is an over simplification of what you would need to in the database itself. You would need a table for the customer information, a table for inventory, etc. But this is the basic idea of how you might store form data.
I am not an experienced Java or JavaScript programmer, so there are limits to what I can help you with here.