copyMatchingColumns copying PK to destination record

Servoy 3.5.3

I am having a problem with copyMatchingColumns() overwriting the PK of the destination record, which if I understand the documentation correctly it is not suppose to do this?

I have the following code…
( I have autoSave = false because all PK’s are db identity)

var new_carton_foundset = databaseManager.getFoundSet(controller.getServerName(), 'carton');
var new_carton_record = new_carton_foundset.getRecord(new_carton_foundset.newRecord(false, true));
databaseManager.saveData();
databaseManager.copyMatchingColumns(current_carton_record, new_carton_record, true);

for (i=1; i <= current_carton_record.fk_carton_item_to_carton.getSize(); i++) {
    current_ci_record = current_carton_record.fk_carton_item_to_carton.getRecord(i);
    new_carton_record.fk_carton_item_to_carton.newRecord(false, true);
    databaseManager.saveData();
    new_ci_record = new_carton_record.fk_carton_item_to_carton.getRecord(new_carton_record.fk_carton_item_to_carton.getSelectedIndex());
    databaseManager.copyMatchingColumns(current_ci_record, new_ci_record, ['carton_item_quantity', 'id_carton']);
}

Now if i put a breakpoint right before the databaseManager.copyMatchingColumns(current_ci_record, new_ci_record, [‘carton_item_quantity’, ‘id_carton’])) I see the PK for new_ci_record equal to something like ‘DbIdentValue3099306’, after the copyMatchingColumns() it gets set to the value of the current_ci_record PK, also column ‘carton_item_quantity’ gets copied over into new_ci_record even though it should have been excluded (id_carton does seem to get excluded)

I’m actually seeing some rather strange inconsistent behavior with copyMatchingColumns() when I try to exclude columns. Sometimes it seems to not overwrite ‘id_carton’ like i mentioned it does (correct behavior), yet other times it does overwrite the values for no apparent reason.

Am I using this function correctly?

Did you find the cause of this problem ??

I am using this construction too now.
If there is still a problem i might have to work out another way to do this.

Regards,

Hans Nieuwenhuis

The issue I mentioned in the first post seems to have resolved itself, not quite sure how though :?
And the second post where it was copying over items even though I told it not to still is hit or miss, so in that case after doing the databaseManager.copyMatchingColumns() I just ‘null’ out the ones I didn’t want to copy and that works every time :)

Can one of the Servoyans please comment on this ?

I am planning to use this feature a lot, so i would like to know if there is a known issue ?

Regards,

Hans Nieuwenhuis