function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
abhinav Krabhinav Kr 

Master-Detail Relation Question

Hi Everyone,

I have a question on Master-Detail Relationship;-

I have created a Master (as School) and Detail as (Class8, Class 9, Class 10)

Is it possible to delete the Master (School) ?
When I am trying out this scenario is shows as "Your attempt to delete School could not be completed because it is associated with the following relationships with other objects." and below that displays a table with two column as "Object Type" (Class8, Class 9, Class 10) and "Relationship" (School).
Please reply as asap.
Carlos Campillo GallegoCarlos Campillo Gallego
Hi abhinav,

You can't delete the master record before deleting its childs. If you want to keep those child records, your master-detail relationship must allow to reparent childs so that you reparent them and then delete the Master record.

Regards.
abhinav Krabhinav Kr
Thanks a ton Carlos.
anto nirmalanto nirmal
Hi Abhinav,

Master Detail Relationship is a relationship field created in the child object pointing to another object.
If you need to delete the Parent Object, the relationship field availble in the child objects does not makes sense.
Hence, If you need to delete the parent object, First you need to delete the relationship field in all the child objects, and only then you could go ahead and delete the parent object.

In your example, inorder to delete the school object, You need to go the the fields section for the child objects(Class8, Class 9, Class 10) and find the relation ship field to the school and delete it. After this if you try and delete the parent object, shcool. You should be able to delete it.

Let me know if this helps.

As a common practice, if your question is answered, please choose 1 best answer.
Additionally you can give every answer a like if that answer is helpful to you.

Regards,
Anto Nirmal
 
abhinav Krabhinav Kr
Hi Anto,

It is really helpful, thanks a lot.
abhinav Krabhinav Kr
Hi Carlos/Anto,

You talked about "Allow Reparenting" child in master-detail relatioship.
Is it like after reparenting the children, parent can be deleted or it means something else.

I tried this scenario:-
I createa a Master (Apartment) with two Details (Flat A, Flat B) and checked the "Allow Reparenting" checkbox.
Still i am not able to delete the Master (Apartment).
Please comment.
Carlos Campillo GallegoCarlos Campillo Gallego
Hi abhinav,

You must fill the parent field of those Details records with another parent different to the one you want to delete, once there is no detail record left with the parent you want to delete, you should not receive any error message.

Regards