How can i obtain all users that i have in bonita , and put them into select box of a form ?

Hi everybody ,

I have a form that contain a select box, in order to fill it with users, i used a conector where i have done an mysql query to retrieve the users. In order to do this i have used this groovy script:

List result = new ArrayList();
while (resultset.next()){
	
List  sousListe = new ArrayList();
sousListe.add(resultset.getString(2));
	
result.add(sousListe);
}
return result;

I managed to retrieve the users , but when deploy the select box i see the data in this format:
[ username ].

I think that is because i’m saving the results in arrayList, and as i’m begginer of groovy script , i don’t know how i resolve the problem , so:

  • ¿Is it possible to retrieve the usernames using an other way?
  • ¿Is it possible to save the users from organization in a variable?

Regards.

You either have to return from your SQL query a JSON Object and use that or build your own transform mechanism to build the JSON String.

these are based on PHP :slight_smile: so you will have to change to groovy - I’m sure a google search will find something.

See here:

http://www.kodingmadesimple.com/2015/01/convert-mysql-to-json-using-php.html

or here

http://www.techrecite.com/how-to-create-json-using-data-from-mysql-database/

regards
Seán

Give a man a fish, and you feed him for a day; show him how to catch fish, and you feed him for a lifetime

Oh OK then, have a look here:

http://www.groovy-lang.org/json.html

and here

http://stackoverflow.com/questions/20999543/groovy-convert-object-to-json-string

regards

Hi ,

I know how to convert any data to json structure , now i’m not asking about php themes, because i’m trying to program a groovy script , and that i know , no is possible to execute php code or javascript (any code except groovy) in a conector from bonita studio. or yes?

my qustion is :

  • ¿Is it possible to retrieve all the users that i have in my organization and then save them in a variable, previously created?

  • ¿Are there any other way to retrieve the users using mysql query into a conector, using any other code ?

My idea is put these users, in a select boxes , because these users , i will use them in order to assign them human tasks.

If you remember , i asked you in other question , and is still not finished :

here an other:

Regards.