How to write to MySQL Database using Editable Grids in Bonita-5.6?

Firstly draw flowchart as shown:

  1. Skipping the first form
  •  Click inside pool rectangle and click on Application Tab in Details Panel.
  • Click on form tab and check the checkbox Skip. It will skip the starting form.

2. Declaring global variable: Click on General Tab and click Data

  • Click on Add button. Add a variable dialog box will appear.
  • Give the variable name as “javalist” and data type as Java Object.
  • Click on Browse button and choose java.util.list
  • Click OK.

3. Creating Form for the first Step i.e Fill grid and it will enter in database.

  • Click on step “Fill grid and it will enter in database”, click Add button in Application>Form of Details panel.
  • Remain checked(ticked) “javalist” variable and click OK.
  • Note: Variable name is “javalist” without double quotes.
  • Drag and Drop editable grid widget in the form.
  • Click on editable grid widgets and in details panel, click data.
  • Make settings as shown:

In this, id,Dept_id etc are horizontal row headers that can’t be changed by the user and will not enter into database too. You can add as many columns as you want by clicking on Add Columns, Add Rows etc.

javalist is the global variable that we declared earlier in the previous steps.

4. Create a connector on first step.

  • Click on Connectors>Add in details panel.
  • Choose scripting>Groovy.
  • Give the name of groovy script.
  • Choose current settings.
  • Copy paste the following code:
import groovy.sql.Sql;
import providedscripts.BonitaSql; 
import java.sql.Driver;
def Integer n = javalist.size();
def String str;
def host = "localhost:3306";
def user = "bonita";
def pass = "bpm";
def schema = "bonita_journal";
for (int i=0; i<n; i++) 
{sql = BonitaSql.newInstance("jdbc:mysql://$host/$schema","$user","$pass", new com.mysql.jdbc.Driver());

def String s1 = javalist.getAt(i).get(0)
def String s2 = javalist.getAt(i).get(1)
def String s3 = javalist.getAt(i).get(2)
def String s4 = javalist.getAt(i).get(3)
def String s5 = javalist.getAt(i).get(4)
def String s6 = javalist.getAt(i).get(5)
def String s7 = javalist.getAt(i).get(6)
def String s8 = javalist.getAt(i).get(7)
def String s9 = javalist.getAt(i).get(8)
query="insert into `bonita_journal`.`employee` (`id`,`Dept_id`, `Title`,`First_Name`,`Middle_Name`,`Last_Name`,`Designation`,`Leaves_Taken`,`Teaching`) values('" + s1 + "','" + s2 + "', '" + s3 +"', '" + s4 + "', '" + s5 + "', '" + s6 + "', '" + s7 + "','" + s8 + "','" + s9 + "');" 

Use Message widget and give the initial value as:

“Your query has been inserted in database”

5. Click on step “Done” and add form.

  • Use Message widget and give the initial value as:
  • “Your query has been inserted in database”

6. Click Save and Run the process.

About Priyanka Kapoor

Simple, Hardworking & friendly.....
This entry was posted in Uncategorized. Bookmark the permalink.

7 Responses to How to write to MySQL Database using Editable Grids in Bonita-5.6?

  1. Thanks a ton for Posting this. It helped a lot.:-)

  2. Can you help me in showing database values in Editable grids and updating them?

  3. Emily says:

    excellent article. very interesting to read. i really love to read such a nice article. thanks! keep rocking.

  4. Erlese says:

    i came to your blog searching through google, and i’m glad i found it because it’s helping me a lot.

  5. Caterina says:

    that is a fantastic story! congratulations on walking through those doors of opportunity!

  6. your website is the most informative. i loved your website a lot. thank you. lista de emails lista de emails lista de emails lista de emails lista de emails

  7. OneUP says:

    Trick question: if the ID/key field is static i.e. you need to use it to update the source record instead of inserting a new record -> how can you populate this ‘hidden id’ field in an editable grid and still retain record order, so that when you use the saved arraylist, you can pair it to the src record key which needs update?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s