Couldn't do a sort because there where edited records on ...

Hi,

I am trying to sort a foundset before it gets sent to Jasper Reports for viewing.
However, after sometime the following error was prompted in the display:

“Couldn’t do a sort because there where edited records on this foundset”

So what I did was I tried creating a duplicated copy of the foundset through the codes below so that I would not mess with the original foundset:
copyOfFoundset = foundset.unrelate();
copyOfFoundset.sort(“columns asc”);

But it does not create another foundset, it only creates a reference to the original one.

How do I create another copy of foundset so that when I sort the foundset it would not have the error above?

Thanks.

unrelate() does only something if the foundset is really a related foundset
you want to use duplicateFoundset()

You will have to call saveData() anyway before being able to sort, the data change is independent of the foundset.

Thanks for the reply. I will try your suggestions.

ngervasi:
You will have to call saveData() anyway before being able to sort, the data change is independent of the foundset.

thats not true (anymore)

a foundset only can’t be sorted if his own records are editing (or it has new records, also new records copied from a duplicateFoundset call)

but if you have a changed records and you make a copy through duplicate, then the changed record is only referenced in the original not in the duplicated.

jcompagner:

ngervasi:
You will have to call saveData() anyway before being able to sort, the data change is independent of the foundset.

thats not true (anymore)

a foundset only can’t be sorted if his own records are editing (or it has new records, also new records copied from a duplicateFoundset call)

but if you have a changed records and you make a copy through duplicate, then the changed record is only referenced in the original not in the duplicated.

Nice feature!
Since when is this available?

i think this should already work in the 4.x
it could be that we had a bit more restricted behavior before.

for example databaseManager.getFoundset() also always can be used to search and sort, even if you have another foundset that has edited records (on the same table)

jcompagner:
i think this should already work in the 4.x
it could be that we had a bit more restricted behavior before.

for example databaseManager.getFoundset() also always can be used to search and sort, even if you have another foundset that has edited records (on the same table)

databaseManager.getFoundset() works fine as you say, I’m not sure about duplicate() in 4.x.
Good to know anyway.