Dynamic form + dynamic variables

Hello!

I want to edit my form and add new field and variables dynamically, I tried this code:

function _btnAddElement(event) {
	
 	var __sForm = event.getFormName();
 	application.output(__sForm);
	var _form = solutionModel.getForm(__sForm);

	var _varTextFiled2 = _form.newFormVariable('variabile',JSVariable.TEXT);
	_varTextFiled2.defaultValue = '"Ciao"';
	_varTextFiled2.variableType = JSVariable.TEXT;

        var field2 = _form.newField(_varTextFiled2,JSField.TEXT_FIELD,2,300,200,25);

	controller.recreateUI();
}

but in this way i create a new field but it isn’t associated to the new variable, I think that the problem is the controller.recreateUI() it re-create only the GUI.

What version of Servoy did you use?
Does if work with a global variable instead of a form variable?

Btw, you are using controller in the last line where I think you would want to use forms[__sForm].controller.

Servoy version: 6.0.6

i tried with an global variable but nothing, i tried also to put

forms[__sForm].controller.recreateUI();

but nothing… my textField is empty.

In the debugging i can see my variable but not in the GUI

Please report this problem.
In my test it does work when I use a global variable:

solutionModel.newGlobalVariable('variabile',JSVariable.TEXT)

With the global variable now works.

I report the problem: https://support.servoy.com/browse/SVY-2047

Thanks for help