How to delete children records?

Questions and answers on designing your Servoy solutions, database modelling and other 'how do I do this' that don't fit in any of the other categories

How to delete children records?

Postby pbdavis » Thu Apr 11, 2019 6:42 pm

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.
Code: Select all
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?
Paul Davis
Belcan Engineering Group, LLC
pbdavis
 
Posts: 34
Joined: Thu Nov 30, 2017 5:40 pm
Location: Florida, USA

Re: How to delete children records?

Postby mboegem » Thu Apr 11, 2019 7:55 pm

Hi Paul,

Just a wild guess, since I don't know what your solution looks like.
I think you have to relations in your solution:
1) child_to_parent
2) 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.

Hope this helps.
_____________________
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance SAN Developer

Image
User avatar
mboegem
 
Posts: 1514
Joined: Sun Oct 14, 2007 1:34 pm
Location: Hoofddorp, The Netherlands

Re: How to delete children records?

Postby pbdavis » Thu Apr 11, 2019 8:50 pm

Awesome Marc! That was it. There was a child_to_parent relation with 'Delete related record' checked.
Thanks some much. This one had me stumped.
~Paul
Paul Davis
Belcan Engineering Group, LLC
pbdavis
 
Posts: 34
Joined: Thu Nov 30, 2017 5:40 pm
Location: Florida, USA


Return to Programming with Servoy

Who is online

Users browsing this forum: No registered users and 2 guests