Problem with ConvertToDataSet and array

Questions, tips and tricks and techniques for scripting in Servoy

Problem with ConvertToDataSet and array

Postby Adelo Herrero » Tue Aug 17, 2010 7:43 pm

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

Code: Select all
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.
Adelo Herrero
Adelo Herrero
 
Posts: 103
Joined: Sat Jul 25, 2009 9:24 pm
Location: Requena (Valencia) España

Re: Problem with ConvertToDataSet and array

Postby lvostinar » Wed Aug 18, 2010 9:00 am

What Servoy version are you using ? What does this return: databaseManager.convertToDataSet(selection) ? (there have been some fixes in databaseManager.convertToDataSet lately)
Laurian Vostinar
Servoy
lvostinar
 
Posts: 1062
Joined: Tue Feb 19, 2008 10:53 am

Re: Problem with ConvertToDataSet and array

Postby Adelo Herrero » Wed Aug 18, 2010 9:17 am

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.
Adelo Herrero
Adelo Herrero
 
Posts: 103
Joined: Sat Jul 25, 2009 9:24 pm
Location: Requena (Valencia) España

Re: Problem with ConvertToDataSet and array

Postby lvostinar » Wed Aug 18, 2010 1:25 pm

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.
Laurian Vostinar
Servoy
lvostinar
 
Posts: 1062
Joined: Tue Feb 19, 2008 10:53 am

Re: Problem with ConvertToDataSet and array

Postby Adelo Herrero » Wed Aug 18, 2010 2:24 pm

Adelo Herrero wrote:...
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:
Code: Select all
forms.test.foundset.loadRecords(selection)


Thaks
Adelo Herrero
Adelo Herrero
 
Posts: 103
Joined: Sat Jul 25, 2009 9:24 pm
Location: Requena (Valencia) España

Re: Problem with ConvertToDataSet and array

Postby lvostinar » Wed Aug 18, 2010 2:45 pm

no, something like:
- create an empty dataset
- iterate over all selected indexes, get the pks and add in dataset
- call fs.loadRecords(dataset)
Laurian Vostinar
Servoy
lvostinar
 
Posts: 1062
Joined: Tue Feb 19, 2008 10:53 am

Re: Problem with ConvertToDataSet and array

Postby Adelo Herrero » Wed Aug 18, 2010 3:53 pm

ok, I prove it.

Thanks.
Adelo Herrero
Adelo Herrero
 
Posts: 103
Joined: Sat Jul 25, 2009 9:24 pm
Location: Requena (Valencia) España


Return to Methods

Who is online

Users browsing this forum: No registered users and 11 guests

cron