Stale Form Error with Form Instances

We’ve started relying heavily on form instances in our solution. The piece of code below would have worked fine when were were dealing with a single form. But now that there are two instances, we are constantly getting the “Stale forms detected” error. I am using the recreateUI function as soon as I am finished modifying the base form. So I am not sure what is causing the error? Any insight would be appreciated.

		var _jsForm = solutionModel.getForm('task_tasksRequiredStock_nav_tbl');
		if (_jsForm.dataSource != 'mem:requiredPartsTree') {
			var _jsForm = solutionModel.getForm('task_tasksRequiredStock_nav_tbl');
			var _uri = _dataset.createDataSource('requiredPartsTree');
			_jsForm.dataSource = _uri;
			forms['task_tasksRequiredStock_nav_tbl'].controller.recreateUI();
			forms['task_tasksRequiredStock_nav_tbl'+_instance].controller.recreateUI();
		}

what is exactly the error?
which forms does servoy still finds stale?

The error is:

Stale form(s) detected, form(s) were altered by the solution model without destroying them first
The form(s) that are stale (can also be a parent form if form inheritance is used) are: task_tasksRequiredStock_nav_tbltask_tasksRequiredStock_nav_tbl,task_tasksRequiredStock_nav_tbl_0

It says both forms are stale even though I called recreateUI() on both forms.

what is the line:

task_tasksRequiredStock_frm.js:409

Because somehow on that line you touched the form ‘task_tasksRequiredStock_nav_tbl’ and that has the instances task_tasksRequiredStock_nav_tbl,task_tasksRequiredStock_nav_tbl_0
that are not recreated or destroyed after that line.

The code in my first post is where the error is stemming from:

var _jsForm = solutionModel.getForm('task_tasksRequiredStock_nav_tbl');
      if (_jsForm.dataSource != 'mem:requiredPartsTree') {
         var _jsForm = solutionModel.getForm('task_tasksRequiredStock_nav_tbl');
         var _uri = _dataset.createDataSource('requiredPartsTree');
         _jsForm.dataSource = _uri;
         forms['task_tasksRequiredStock_nav_tbl'].controller.recreateUI();
         forms['task_tasksRequiredStock_nav_tbl'+_instance].controller.recreateUI();
      }

Line 409 is _jsForm.dataSource = _uri; I immediately call recreateUI() on both forms, but I still get the error.

please create a case with an example then.
because recreating should work.

I opened up a case (272941) and included a sample solution