dataprovider type from a related table

I was wondering if anyone knows how to retreive a dataprovider type from a related table?

I think I can do a couple splits of the returned value and then rerun the databaseManager.getTable(“kv_orders”).getColumn(“split_value”).getTypeAsString()) but was wondering if there was an easier way to do this?

Okay so this is what I have done.

var lv_dataProvider = lv_element.getDataProviderID().split('.');
      var lv_dataProvider_table = new Array();
      (lv_dataProvider.length > 1)?lv_dataProvider_table = lv_dataProvider[0].split('_to_'):lv_dataProvider_table.push(databaseManager.getTable(form.foundset).getSQLName());
      
      lv_searchFieldValues.push(new Array(lv_element.getName(),databaseManager.getTable(globals.security_current_database_server, lv_dataProvider_table[lv_dataProvider_table.length - 1]).getColumn(lv_dataProvider[lv_dataProvider.length - 1]).getTypeAsString()));

Thanks

Paul,

You can also get everything before the dot in the dataprovider (if there is a dot).
If you eval that you will get a related foundset that has a getDataSource() method.

Via databasemanager.getTable(fs).getColumns(stuffafterdot) you have the column.

This way you are not depending on any naming convention for relations.

Hope this helps,

Rob

Thanks for the reply Rob.

Would you be able to supply a little code for this example? I am trying the following and not able to get a foundset from the eval.

var fs = eval(lv_dataProvider[0]);

Something like this?

var dpstring = 'myrel1.myrel2.dp'	
var idx = dpstring.lastIndexOf('.')
if (idx >= 0)
{
  fs = eval(dpstring.substring(0, idx))
}

Rob

you can get into trouble using the eval() function. (BTW Servoy is always telling us NOT to use the eval() ! :wink: )
for example if you fire this code in another module, where this relation does not exist you will get an error

Most of the time you know also the scope or name of the form.
so I should do it this way:

var vEvent = arguments[0] //get the event object
var vForm = vEvent.getFormName()
var vDP = 'myrel1.myrel2.dp'		
var vIdx = vDP.lastIndexOf('.') 
if (vIdx >= 0) {
     var vFS = forms[vForm][vDP.substring(0, vIdx)]
}