solutionmodel disappears

Hi!

I am creating the dataset and datasource programmatically

var _dataset = createDataSet(_columns);
var _dataSource = createDataSource(_dataset);
var thisForm = solutionModel.getForm(controller.getName());

and got this error after executing this line

history.removeForm(controller.getName()

“Error during evaluation:ReferenceError: "solutionModel" is not defined.”

I am using servoy Version: 5.2.9 - build 1020

Thanks!

Let’s say the error does not just come up. But if I try to access solutionModel - that’s what I get: “Error during evaluation:ReferenceError: "solutionModel" is not defined.”

There are other places where we remove forms from history but nothing like this happens. Is this some sort of Servoy bug?

Cheers,
Maria

This code:```
history.removeForm(controller.getName());


Since Servoy 5.0 it is not necessary anymore to remove forms from the history to make changes to them. Instead you have to call controller.recreateUI() at the end of your changes.

Having said that, the error you get should never happen. Does it give any more information in the log file?

Joas:
This code:```
history.removeForm(controller.getName());


Since Servoy 5.0 it is not necessary anymore to remove forms from the history to make changes to them. Instead you have to call controller.recreateUI() at the end of your changes.

Having said that, the error you get should never happen. Does it give any more information in the log file?

The history.removeForm always return false.

function assignDataSourceToForm(datasource){
var my_form = “myform”; // form is inside panel

if(history.removeForm(my_form) == false) {
application.output(“cannot remove form from history”);
}

var thisForm = solutionModel.getForm(my_form);
thisForm.dataSource = datasource;
forms[my_form].controller.recreateUI();
}

The recreateUI still does not work. The function is called onShow of the mainform.

Thanks!

recreateUI is about the UI (as the name tells you that)
But setting the datasource is the data layer of the form, then recreateUI doesn’t work because there is no change in the UI, just in the data
And for data you have to destroy and recreate the form. This can only be done in a none visible form that is not executing any methods.

jcompagner:
recreateUI is about the UI (as the name tells you that)
But setting the datasource is the data layer of the form, then recreateUI doesn’t work because there is no change in the UI, just in the data
And for data you have to destroy and recreate the form. This can only be done in a none visible form that is not executing any methods.

I am lost. Can you guide me? Do you mean I need to create another form that will call removeForm then do the changes in data and call show?

you have to hide the form (so not show it)
call history.remove() on it (do check the return type!)

then you can show the form again after you changed it and then you changes should go through