How to duplicate a foundset's specific columns

I need to duplicate certain columns from a foundset. I need to do this for multiple tables in the relation
What is the best way of doing this ?
I want to do something like this …

    for(i in selected_pk)
     {
      var pk = foundset.selectRecord(selected_pk[i][0]);
      var dupFoundset = foundset.duplicateFoundSet();
      foundset.newRecord(); 
      foundset.pk_id = pid;//from sequence
      foundset.a = 'xx';

   //fill in remaining columns from dupFoundset
        foundset.x = dupFoundset.x ;
        foundset.y = dupFoundset.y ;

    //etc   ....

     }

Take a look at databaseManager.copyMatchingColumns(), see the sample code below:

	//Copies all matching non empty columns (if overwrite boolean is given all columns except pk/ident, if array then all columns except pk and array names), returns true if no error did happen
	for( var i = 1 ; i <= foundset.getSize() ; i++ )
	{
		var srcRecord = foundset.getRecord(i);
		var destRecord = otherfoundset.getRecord(i);
		if (srcRecord == null || destRecord == null) break;
		databaseManager.copyMatchingColumns(srcRecord,destRecord,true)
	}

Thanks I will try that