Html-widget-groovy-javascript-increase counter-variable
Hellooooooo,
Could anyone give me an example in:
How could i increase a counter in Bonita 5.9 in html widget??? I have define a counter as global-variable in Bonita Studio and i have a problem to increase the counter-variable. The main reason of that is , in Groovy Editor,(which i write code) , is not supported to write html-code or javascript without these symbols----> " "
What is that i make a mistake? For example:
" "+ "
"+
"<body>"+
"<p id='demo'></p>"+
"<script>"+
"var tmp="+(counter+1) +";"+ //COUNTER: IS GLOBAL VARIABBLE IN BONITA STUDIO
"var x='<table>';"+
"x=x+'<tr><th>ΑΡΙΘΜΟΣ ΑΙΤΗΣΗΣ</th><th>ΤΡΑΠΕΖΑ</th><th> ΗΜΕΡΟΜΗΝΙΑ </th><th> ΚΑΤΑΣΤΑΣΗ </th></tr><tr>';"+
"for (var i=0; i<5;i++){"+
"var adder='"+counter+"';"+ //IN THESE STEP,I WOULD LIKE TO INCREASE THE VARIABLE COUNTER,EVERY TIME TO RUN THE FOR-LOOP-.HOW CAN DO IT?
" x=x+'<tr>';"+
" x=x +'<td>'+ 'The number of application ' +adder + '</td>';"+
" x=x +'<td>'+ 'The Status is ' + tmp +'</td>';"+
" x=x+'</tr>';"+
" }"+
"x=x+'</table>';"+
"document.getElementById('demo').innerHTML = x;"+
"</script>"+
"</body>"+
"
"<body>"+
"<p id='demo'></p>"+
"<script>"+
"var tmp="+(counter+1) +";"+ //COUNTER: IS GLOBAL VARIABBLE IN BONITA STUDIO
"var x='<table>';"+
"x=x+'<tr><th>ΑΡΙΘΜΟΣ ΑΙΤΗΣΗΣ</th><th>ΤΡΑΠΕΖΑ</th><th> ΗΜΕΡΟΜΗΝΙΑ </th><th> ΚΑΤΑΣΤΑΣΗ </th></tr><tr>';"+
"for (var i=0; i<5;i++){"+
"var adder='"+counter+"';"+ //IN THESE STEP,I WOULD LIKE TO INCREASE THE VARIABLE COUNTER,EVERY TIME TO RUN THE FOR-LOOP-.HOW CAN DO IT?
" x=x+'<tr>';"+
" x=x +'<td>'+ 'The number of application ' +adder + '</td>';"+
" x=x +'<td>'+ 'The Status is ' + tmp +'</td>';"+
" x=x+'</tr>';"+
" }"+
"x=x+'</table>';"+
"document.getElementById('demo').innerHTML = x;"+
"</script>"+
"</body>"+
"
"
2 answers
Hi,
Here is a working example using the code provided above: http://we.tl/PFmQfFgm0Z
Cheers, Francois
Comments
Firstly,Thank u a lot for your answer!! :)) Could you to resend the example??But the type of the file is *.proc OR *.bar OR *.bpmn??? As MyDiagram2-1.0.bos ,i cannot opened it!!!
Thank again in advance Katerina
Hi,
Sorry, I forgot you were on 5.X. My export comes for a Studio 6.2 I don't have a 5.x installed on my machine currently, but it will be the same exact groovy code. In your html widget, just copy this:
"<script>"+
"var tmp="+(counter+1) +";"+ //COUNTER: IS GLOBAL VARIABBLE IN BONITA STUDIO
"var x='<table>';"+
"x=x+'<tr><th>ΑΡΙΘΜΟΣ ΑΙΤΗΣΗΣ</th><th>ΤΡΑΠΕΖΑ</th><th> ΗΜΕΡΟΜΗΝΙΑ </th><th> ΚΑΤΑΣΤΑΣΗ </th></tr><tr>';"+
"for (var i=0; i<5;i++){"+
"var adder='"+counter+"';"+ //IN THESE STEP,I WOULD LIKE TO INCREASE THE VARIABLE COUNTER,EVERY TIME TO RUN THE FOR-LOOP-.HOW CAN DO IT?
" x=x+'<tr>';"+
" x=x +'<td>'+ 'The number of application ' +adder + '</td>';"+
" x=x +'<td>'+ 'The Status is ' + tmp +'</td>';"+
" x=x+'</tr>';"+
" }"+
"x=x+'</table>';"+
"document.getElementById('demo').innerHTML = x;"+
"</script>"
- See more at: http://community.bonitasoft.com/answers/html-widget-groovy-javascript-increase-counter-variable#node-14304
Cheers, Francois
François, did you created the example process with a Subscription version ?
Yes I did, but there is nothing specific to SP version in the groovy script provided.