createDataSource()

Hi,

I have a question about createDataSource(); this is what i do;

var v_sql = "SELECT fields FROM table"
var v_ds  = databaseManager.getDataSetByQuery("server",v_sql,null,-1);

var vDatasource = v_ds.createDataSource('dataSource',[JSColumn.TEXT,JSColumn.TEXT,JSColumn.TEXT,JSColumn.TEXT,JSColumn.TEXT,JSColumn.TEXT]);
	
var v_form = solutionModel.getForm('MyForm')
v_form.dataSource = vDatasource;
	
var fld_1 = v_form.getField('field1);
fld_1.dataProviderID = "field1";
etc.

controller.recreateUI();

My question; How can i get a reference to the dataSource of the form, in a separate method, i want to loop through it to get the values.
in my query i use a dummy column that can be filled in on the form by the user, in my “save” method i want to get that values.

Thanks in advance.

Hi Maurice,

First, when creating a form with a custom datasource you should keep the dataset in a form/global variable so it persists.
Now this form will act just like any other form with a table connected (except that you can’t add records) so you can loop through the foundset.
If you want to add records you do that on the dataset you are still referencing in a form/global variable which will show up instantly in your form.

Hope this helps.

Thanks Robert, that’s what i was looking for!