Refresh forms based on dataset not working

Hi,

I have forms based on datasets.
From a dataset you make a datasource.
This datasource name is something like “mem:”

Using the solutionmodel this datasource is connected to the form.
This works until you want to refresh the form with a new dataset.
Impossible to refresh the form with a new dataset.

var filter = 'R%';

var nr_of_records = null;

function onAction(event)
{
	var _query = 'SELECT relation_code, name FROM relations WHERE relation_code LIKE ?'
	var _ds = databaseManager.getDataSetByQuery('myServerName', _query, [filter], -1)
	if (_ds)
	{
		nr_of_records = _ds.getMaxRowIndex()
		
		linkDatasetToDataform('dataForm', _ds)
	
	}
}

function linkDatasetToDataform(_form, _dataset)
{
	if (! _form)
		throw 'Formname missing';

	if (! _dataset)
		throw 'Dataset missing';
	
	var _js_form = solutionModel.getForm(_form)
	if (! _js_form)
		throw 'Form not found ' + _form; 
		
	//	Build array with columnnames (if not provided)	
	/** @type {Array} */
	var _column_names = _dataset.rowColumns;

	var _datasource = _dataset.createDataSource(_form + '_' + utils.stringReplace(application.getUUID().toString().toLowerCase(), '-', '_'))
	
	//	Set the datasource 
	_js_form.dataSource = _datasource;

	var _js_element
	var _js_elements = _js_form.getFields()
	
	for (var i = 0; i < _js_elements.length; i++)
	{
		_js_element = _js_elements[i];
		
		if (_js_element.name && _column_names.indexOf(_js_element.name, 0) != -1)
		{
			//	Set  the dataprovider to the name of the element if this name is result of the query
			_js_element.dataProviderID = _js_element.name
		}	
	}
	
	var _ok = forms[_form].controller.recreateUI()
	if (! _ok)
		throw 'Can not recreate form ' + _form;
	
// Not sure if below is needed
	forms[_form].controller.loadAllRecords()
	
	return;	
}

The recreateUI() is not changing the current datasource of the form to a new datasource.
Therefore once a dataset loaded, the form isn’t refreshed.

Is there some statement that I’m missing?

I’ve also tried:

history.removeForm()
solutionModel.revertForm()

but both do not solve this problem (they are giving even more problems)

This situation occurs both in 5.2 and 6.0.1

Martin,

If you want a form on a datasource and you want to refresh these values, you can reuse the data source.
The second time you call dataset.createDataSource() with the same name, existing forms on that datasource will be refreshed with the new data.

Rob

Thanks Rob,

The problem was that I used a new name for the datasource (I thought new query, so new name)
That was the problem.

Martin