I have a form with relationships. I need the ability to selectively delete the children. I get the child in a record I want to delete. But the deleteRecord(rec) deletes all the children and the parent record in another table.
function onAction(event) {
// Delete selected image record.
var rec = forms.frm_MOD_fsr_image_pict_Edit.foundset.getRecord(1);
application.output("Rec id = " + rec.fsr_image_id);
forms.frm_MOD_fsr_image_pict_Edit.foundset.deleteRecord(rec);
}
Can someone tell me why this is deleting Parent and children? And how to delete just the selected child?
Just a wild guess, since I don’t know what your solution looks like.
I think you have to relations in your solution:
child_to_parent
parent_to_children
If this is the case most likely both relations have the ‘delete related record’ checkbox ticked.
I can imagine this should be the case for the 2nd relation, but definitely not for the first one.
Hi Paul,
although it has been a while since your thread:
When detecting such an issue, you might want to check all relations regarding the “Delete related record” checkbox.
A complete overview of such settings in a table view of all relations would be handy for such a purpose, though I do not know if that is possible somehow.
So far I did not see any example where a parent should get killed when a child has to be deleted.
As this should be very seldom, maybe it would be an idea for the Servoy system to ask “Are you sure to delete the parent as well?” when someone accidently checks that box in a child-to-parent-relation.