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
sekhar rajasekhar raja 

relationship error

hi,

i have problem with relationships.

 

i have created two objects  

1.firstobj

2.secondobject

in the first object i have two fields are available (i)first name,(ii) gender

in second object(i)last name(ii)city

after that i save two records per each object. after that

 

while i am creating master - detail relationship between the  two objects it displays some error message

 

Cannot Create Master-Detail Relationship
You cannot create a new Master-Detail relationship on an existing custom object if records already exist. You must first create a Lookup relationship, populate the lookup field with data in all records, and then change the relationship type to Master-Detail. 

how to overcome this problem?

SabrentSabrent

Master - Detail(1:n) relationship means a parent-child relationship in which the master object controls certain behaviors of the detail object:

 

  • When a record of the master object is deleted, its related detail records are also deleted.
  • The detail record inherits the sharing and security settings of its master record

Therefore, if you want to create a Master-Detail relationship between existing objects, you need to ensure that all the existing records for the child object have a lookup value to the parent object .

 

What you could do is,

1. Create a lookup from the child object to the parent object.

2. Populate ALL the records with a valid lookup value to the parent.

3. Change the Lookup relationship to a Master - Detail relationship.

 

Note that, this is only allowed if All Records Have a Valid Lookup. if not, you'll get the same error.

 

Reference: http://www.salesforce.com/us/developer/docs/api/Content/relationships_among_objects.htm

 

Hope this helps.