Problem with ConvertToDataSet and array

Hi all,

I have an array of selected items in a foundset and want to create another foundset with them.

I use the following code

var selection = forms[frm].foundset.getSelectedIndexes();
var fs=databaseManager.getFoundSet('server','table');
fs.loadRecords(databaseManager.convertToDataSet(selection));

And I get this error:
argument type mismatch
Wrapped java.lang.IllegalArgumentException: argument type mismatch

In the debugger, the valor of “selection” is [1,3]

Any idea?

Thanks.

What Servoy version are you using ? What does this return: databaseManager.convertToDataSet(selection) ? (there have been some fixes in databaseManager.convertToDataSet lately)

Thank you for responding:

I use Servoy Version: 5.1.4 - Build 964, and I get the same result on both Windows XP, OSX and Ubuntu 10.

Hmm, didn’t notice before, but the code is not ok. You can load the foundset from pks, and not from indexes. So, having the indexes, you must get the pks, and call load on that.

Adelo Herrero:

In the debugger, the valor of “selection” is [1,3]

The valor of the array elements is the corresponding to the pk’s of the selected records.

The following code if it works:

forms.test.foundset.loadRecords(selection)

Thaks

no, something like:

  • create an empty dataset
  • iterate over all selected indexes, get the pks and add in dataset
  • call fs.loadRecords(dataset)

ok, I prove it.

Thanks.