Simple way to load record into a variable

Is there a simple way to load a record into a variable without building foundset find-search?

I mean a record from any table, not though a relation or on a current form.

Something like:

var record = getRecord( serverName, tableName, pk )

g.

Hi g.

You can do this with SQL and the databaseManager node.
Like so:

var sQuery = "SELECT * FROM tableName WHERE PKColumnName=?;",
	sServername = controller.getServerName(),
	ds = databaseManager(sServername, sQuery , [pkValue], -1),
	aRecord = ds.getRowAsArray(1);

// aRecord is an array with the record data

Hope this helps.

Yea, I don’t really want an array, however. I want the record so that I can directly access it’s fields, calculations, relations, etc.

I really like Servoy, but I’m just dying for it to take that next step to being a Object-Relational mapper by allowing us to define events/methods on the dataprovider level so that records can really model the behavior of the data they hold. I don’t know when or if we’ll get that, however.

Still, short of that, I, I do rely on the record calculations and relations often passing these records around, so right now I’m doing a variety of clunky things to grab a record – usually looping over a related foundset, or such.

I was just hoping I was missing something simpler.

g.

you can load a record into a form on the fly by doing this:

forms.yourFormName.controller.loadRecords( databaseManager.convertToDataSet( [PKId] ) );

I think it is possible to convert this one, in the way you want.

Hope this helps

Right now the forms, relationships etc. ARE the objects. However you can only create them in design mode, not on the fly.
For more advanced OO stuff I suggest you file a feature request.

As for events on the dataprovider level, that is coming in 3.5.