Fetch and Display variable from database

Hello ! 
How to display a process variable of type List of String in the table in the form? 
We can see that Bonita gets the result in the Groovy script if we put directly the value of the variable, for exemple a string ”service”, it gives us a List of String that we want. But if we put the Buisness variable insted of "service" we don't know if it works, because it's value should be given by user's Input. Can you help us : how to properly fetch the user input in groovy? Do we use a connector in,out, operation?

If we put the same script into Operations for a process valuable to take the return value, the flow of the process stops working and we can not see the forms appear anymore.

The general question is : 

- Where to put a script? - How to properly put a business variable in it? -How to put the result of type List of String into the variable and which variable ? - How to display this information in a table in the form? - Is there a way to change the value directly value in the table by user?

------Our script : --------

import groovy.net.xmlrpc.*


def username = "username" //email or username
def pwd = "password"  //password
def dbname = "myTest" // dataBase

/* Connexion via xml-rpc à Odoo*/
def serverProxy = new XMLRPCServerProxy("http://localhost:8069/xmlrpc/common")
def uid = serverProxy.login(dbname, username, pwd)
def odoo =  new XMLRPCServerProxy("http://localhost:8069/xmlrpc/object")

def args = [['type', '=', category.name ]] // Here instead of category name we use 'service' and we can see that it works

def data = odoo.execute(dbname, uid, pwd, 'product.product', 'search_read', args, ['name'])
def list = []
data.each{it -> list += it.name}

return list;

Hi Marcy,

Let me try to rephrase your question to see if I clearly understand it

You want that your user fills some information (category.name) in a form and once it is done, perform a call (your groovy script) to an external service (DB) and provide the output of that call to the end user in a table. 

As example, your end user will select a product category and based on that he will see the list of products of that category.

If I am right, you need a Rest API extension.

  1. Your form have an input where user will fill the category (input, select,...) and set the value to category variable.
  2. You set a button to do a GET call to the url "../API/extension/<yourExtensionName>?category={{category}}", success data will be set to a new variable named "productsOfCategory"
  3. Use the new variable "productsOfCategory" in a table

You will need to create a new rest api extension that accept a new parameter "category" and execute your groovy code to call DB and then provide the data on success and add proper Error handling...

https://documentation.bonitasoft.com/bonita/7.10/api-extensions

 

 

 

Hi again Marcy,

In case you want to use BDM to do the same, here you have an example:

https://community.bonitasoft.com/questions-and-answers/transitions-engine-api