Add variable to json

Hi all!

Actually use Bonitasoft community 7.5.4, well I create a form in the automatically generated UI with the contract.

Also create a javascript variable to calculate the date automatically when starting the form, My quiestion is how can I add a variable to json output of the contract so that it adds that value in the BDM and to call it in another form?

In the input the value is default when is generate automatically whit the fields in the contract and when create the new variable add this variable in the value of the widget but when execute the process this value is not added in the BDM appears as empty, also mi varibale to output is that formiInput type Json.

Hello,

If you need to use some 'var' in JSON, i will recommand you to use Javascript type and do somethinklike:

var json="{\"username\":\""+$data.username+"\",\"address\": {\"country\":\""+$data.formInput.country+"\"}}";


But in your case, i think that you have miss somethink with your input value and your output.
If your form contract have a field : 'username', by default bonita create a form with one input of type 'Text' and a 'formInput' variable of type 'JSON'
This input value need to be a bidirectionnal type with value of: formInput.username
And your formOutput need to be a 'Javascript' type with this content:
return $data.formInput;


Regards,

Hi bastien thanks for you answer!
 

 

I created the JavaScript type variable to calculate the time but in Bonita's videos, they explain that it is good practice to remove formOutput and only use formInput when creating a form and for this reason I delete the variable formOutput.

my question is how can I add the value generated by my variable of type JavaScript to the variable formInput of type JSON? because in the input value I put my JS variable type and therefore when sending it does not add the value to the BDM

 

If you don't use the 'formOutput' variable, what is your form submit button body? 

I use the formInput for submit button!

Ok, and when you use your browser debug, what is the payload of your submission?