Display the content of a database table with a specific process variable defined in a pool

1
0
-1

Hi,

I tried to display the content of a database table with a specific process variable defined in a pool.

Firstable, I have created a process variable in a pool with a static default value.
Then I have configured a "table" widget in the UI and tried to configure a variable as below:
myVarUI=../API/bpm/caseVariable/{{caseId}}/myVar

Nothing is displayed in the result page.
I am not sure about the REST API call.

Can you explain me what is wrong.
Thank you for your feedback.

Comments

Submitted by Sean McP on Tue, 10/06/2015 - 17:37

Is the data in JSON format?

Have a look at the Getting Started tutorial in the documentation to see how it works as there is an example in there.

regards

Submitted by badmtri on Thu, 10/08/2015 - 10:49

Thank you for your feedback.
I have followed the "Getting Started" tutorial. And yes, there is an example in there. But, it only shows how to displ

Submitted by badmtri on Thu, 10/08/2015 - 10:57

Thank you for your feedback.
I have followed the "Getting Started" tutorial. And yes, there is an example in there. But, it only shows how to display dummy data in a local JSON format. There is no explanation about how to display element of a process variable define in a pool using the REST API.
There is no explanation about how to simply display rows of a database table returned by a "select" SQL request.
I don't know if my question is irrelevant. Can you tell me if it is? I have search a lot in the internet and didn't find out the right solution.

Regards

Submitted by Sean McP on Thu, 10/08/2015 - 14:31

No your question isn't irrelevant, it just needs answering... :) That's what we're here for.

OK so you see how the data is formatted in the Getting Started Guide. You first need to ensure your Table Data from the Select Statement is translated into JSON format. Have you done that?

If using mySQL there is a great method of doing this here:

http://www.thomasfrank.se/mysql_to_json.html

Do click CANCEL on the alert - you want to go to the old page. Something similar is available I'm sure for other databases...

Otherwise build your own loop to build the json in script code.

Then have a look at the following for how to use a process variable on a form

http://community.bonitasoft.com/project/process-variable-example

regards

1 answer

1
0
-1

Hi Sean,

i followed your suggestions:
1. How to use a process variable on a form: i understand now the mechanism. I missed in my previous tests to get the task id from the URL. It works fine now.
2. JSON format for widget table: i use PostGreSQL database. I tried a lot of Groovy development to send a JSON format for the variable used in my form. But it didn't work. I tried to format the data the same way i configure it in a local JSON variable. Can you tell me what is wrong in this simple Groovy script:
List result = new ArrayList();
result.add("{");
result.add("\"col1\": \"AZAZAZAZA\"");
result.add("}");
return result

Thanks a lot for your support Sean.

Regards

Comments

Submitted by Sean McP on Tue, 10/13/2015 - 14:25

What you want is

StringBuilder result = new StringBuilder();
result.append("{");
result.append("\"col1\": \"AZAZAZAZA\"");
result.append("}");
return result.toString();

json data is simply a string...

regards
Glad to help

Submitted by badmtri on Tue, 10/13/2015 - 16:35

OK. I return a string:
1. When i display it in a input widget ==> OK. Value {\"col1\": \"AZAZAZAZA\"} is displayed.
2. When i display it in a table widget ==> Nothing is displayed.

Note1: My conf for the table widget is:
a. Content=form_variable1=../API/bpm/activityVariable/{{taskId}}/process_variable1
b. Column keys="col1"

Note2: My conf for the input widget is:
a. Value=form_variable1.value with binding clicked

Notifications