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
Priya M 22Priya M 22 

changing field type from lookup to master details relationship

Hi All,

I have created one lookup relationship field with the Account in a custom object. We have 2-3 records too in Custom object, and for every record lookup field is filled. Still i am getting this error message
"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. "
When i am tring to change its field type. :(
I had even tried deleting up all the records then clearing the recycle bin waited for 24 hours to get it completed removed, nothing worked so far :(
 
Best Answer chosen by Priya M 22
GhanshyamChoudhariGhanshyamChoudhari
Select Id, Name, account.Name From customobj__c where Account.name =null

please find the record which doesn't have an account associated

All Answers

GhanshyamChoudhariGhanshyamChoudhari
Select Id, Name, account.Name From customobj__c where Account.name =null

please find the record which doesn't have an account associated
This was selected as the best answer
FabiFabi
Priya, the only reason  i can think of too is that the object on which you are trying to create the master-detail relationship( your custom object)  already has records and they are not tied to any record in the targeted master object ( Account) . This is due to the fact that  child records can't exists without a corresponding parent record in a master-detail relationship. Hope this helps!
Priya M 22Priya M 22
That i had cross checked several times.. its having value for that (Lookup) field. What if i delete all the records and then wait for 24 hours to get it comepletly deleted from the server.And then try again
Priya M 22Priya M 22

Thanks Ghanshyam and Fabi

It worked, i serached the record via workbench.. for some reason one of the record was not appearing in my org. but in workbech it did thanks a lot :)