Hi All,
I’ve tried pretty much every combination of searches and gone through the tutorials before I got here. My groovy scripting is limited but I’m getting there and seen lots of examples of how to populate an array, map, list. collection… or whatever the method at the time calls it.
I basically have a localhost mssql DB called BonitaSoft, a table called users and 3 columns Firstname (varchar 50), Surname (varchar 50), Title (varchar 8) and ID (Int). I’ve then populated it with 3 test users.
What I want to do is populate a select widget on a form with the Firstname values from this DB. I have tried lots of combinations but the current setup is that I have a process variable called hashMap with a Data type of Java Object and the class set to java.util.HashMap.
I then setup a pool level connection which connects to the local db, does a select * from users and then enters scripting mode. From there I have the process variable ‘hashMap’ take the value of ‘resultset’ and the ‘resultset’ script is -
import java.sql.ResultSetMetaData;
HashMap<String,String> hm= new HashMap<String,String>();
resultset.beforeFirst();
while (resultset.next()) {
String key = resultset.getString('firstname');
String value = resultset.getString('firstname');
hm.put(key,value);
}
return hm;
In a new form that I attached to a human task I’ve added a variable called ‘myListAlt’ with a value of ‘…/API/bpm/caseVariable/{{task.caseId}}/hashMap’ and added a select widget which uses this form variable in the *value * and available values properties.
The best I have managed is for the dropdown to show a single value per row i.e. C, h, r, i, s… and this was done by adding myListAlt.value to the *value * and available values properties in one of the combinations.
Any help appreciated
Thanks