Trying to change the existing relation between A(Parent) and B(Child) from Look up to Master- Detail. Deploying "B__c.A__c" using ANT.

  • Ran a query on B and made sure all B__c.A__c is populated (As per the documentation, if all look up fields are populated, we can convert relation from lookup to master-detail)

During deployment, I am getting error "cannot add master-detail relationship due to existing data rows"

Any idea on resolving this.


  • 1
    Did you also check the recycle bin? You must purge or restore and correct all records, even those in a deleted status.
    – sfdcfox
    Dec 20, 2015 at 6:56
  • Did "Empty Organization recyclebin" as this is sandbox but still getting same error when validating
    – sf_user
    Dec 20, 2015 at 7:00
  • 1
    It might be some sort of time delay between purging and when you can deploy. I don't know why else that error would happen. Try it again later? Hopefully you get this resolved.
    – sfdcfox
    Dec 20, 2015 at 7:02
  • Earlier I tried to do this manually as well. It said "Updating records. We will send email once completed". It has been more than 24 hours but neither get any email nor did the relationship change. So tried using ANT but got the above error message
    – sf_user
    Dec 20, 2015 at 7:04
  • 1
    Once you do empty recycle bin ur records should be deleted. But after this there is physical delete which is done by Salesforce. That process takes time because of which you might be getting this error. You can fasten up physical deletion by raising a case. I got this information from Salesforce support about physical delete. Dec 20, 2015 at 7:18

1 Answer 1


Make sure to check records in recyclebin as well. " You must purge or restore and correct all records, even those in a deleted status"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .