Using input widgets for Calculation (Arithemetical Calculations)

1
0
-1

How can i do this

i followed this tutorial
https://community.bonitasoft.com/questions-and-answers/computed-fields-u...

i have been able to create a custom widget for calculations works fine , but i want to have the same like thing in an input widget (Have the two input widgets use something like a javascript expression to calculate)
It should calculate and give the results in a third input box (Editbox)

I am using the UI Designer and my screen looks like this :

vanos.png

What do i appear to be doing Wrong?

1 answer

1
0
-1

Based on the other question you posted, I think you already find the answer. I'll add an answer to this question anyway as it might be helpful to someone else.

In Bonita forms (also apply to Bonita pages) you usually add various widgets. To define the value of a widget you usually assign the "value" property of the widget to a form variable (or an attribute of the form variable, e.g. : myVariable.myAttribute). A form variable is a JavaScript object that can be initialized from a REST API call that return a JSON, using a static JSON value or using a JavaScript expression that can mix other form variables values to create the new variable value.

So for your use case you simply need to define a JavaScript variable that will store the result of your calculation and that use the existing variable associated with the "number of nights" and "perdiem" widgets. Note that in a JavaScript you can access form variables using $data.formVariableName.

Notifications