Populate one or more variables defined at process level from a unique groovy connector

1
0
-1

Hallo Gurus I'm new for Bonita and new For java. I work with bonita 6.3. I have made a Workflow that work with a Oracle database. But I have too many connector. The idea is to have one unique connector to populate at the beginning of the process all my global variable. But this idea not work.

The question is Can I populate all my process data (defined at process level) with a simply assignment made into a unique groovy connector? For example I have two global data "p1" and "p2" and a global list "my_list" and a groovy connector (scripting groovy). This data and the connector are defined at process level.

I execute the following code

import groovy.sql.Sql def String query="select data1,data2 from bonita_parameters where ID=1" // This return only one record

Sql sql = BonitaSql.newInstance( jdbcURL, jdbcUsername, jdbcPassword, new oracle.jdbc.OracleDriver()) sql.eachRow(query,{row-> p1 = row.data1 p2 = row.data2 });

def list=[:] query="select desc,id from TABLE_1 order by 1,2" // This return many record and i Use this list for populate a "List Widget" in my form sql.eachRow(query,{row-> list.put(row.descrizione,row.id)}); sql.close();

my_list=list

But at the end of this script (that work fine) my variables is empity. Thank in advance Regards

Comments

Submitted by ttoine on Mon, 06/02/2014 - 18:09

Hello, why are you using a groovy code with a SQL query, instead of using a database connector ?

Submitted by mos on Mon, 06/02/2014 - 18:35

Hello Thanks for the comment and the answer. Actually I use Oracle connectors for populate various list that I use for the dropdown list widgets of my forms. I would organize my code to group all the query in only one script. I now that i must map the result of one script to one variable, but this is my problem: the script have only one result (is this true?). Can I have more results from a Groovy script? (so I can map each result with a different variable) Thanks

1 answer

1
0
-1

Hello,

Instead of doing assignments within the script, you should map result returned by your script to your variable on the Output operations definition screen. If you want to populate more variables with the same connector, you should add more operations on your Output operations screen of the connector configuration, and map different values to different variables. As a general recommendation, you should use the out-of-the-box Oracle connector, instead of a Groovy script.

Hope this helps, Haris

Notifications