Making a copy of a foundset to keep in memory

I want to make a copy of my foundset and put it into an (object)variable.

The use of this functionality is, that I want to keep an exact copy of the foundset in memory without having to do a requery on my database.
That is why I don’t use the databaseManager.getSQL(foundset) and databaseManager.getSQLParameters(foundset) functions.

  var _foundset = forms[_form].foundset;
	var _progobj = globals.nav.program[_program];  // This is an Object
	
	_progobj.related_foundset = _foundset.duplicateFoundSet()
	_progobj.related_foundset.unrelate();

So I make a duplicate of the foundset and I put this in an objectvariable .
Extra I do also a call to unrelate()

But what I see that when the original foundset is changed, that the foundset in the objectvariable is changed also.
That is not what I want. I want the objectvariable to keep the original foundset

This is Servoy 3.5.7.

Is there a way to achive this?

Martin

Your duplicate is not a real duplicate but a reference to the original.

For what you want you would have to clone the foundset (not possible ‘out of the box’ as far as I know).

But why don’t you use dataset? That is static…

duplicate is a clone with exactly the same initial state as the original but if you then change the original (do a new query)
the duplicate shouldnt change (also have that new query)

So what do you mean with changed? what is changed in the original foundset? A record? That will be shown in the duplicate also ofcourse.