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
sfdc-apexsfdc-apex 

Converting Lookup field to Master-Detail Relationship

Hi all,
 
I have been trying to convert a lookup field to master detail relation field, while we were changing the field type we encountered an error message saying
"There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Generic Exception Creator".
 
We also tried creating a new Master-Detail Field instead of converting the existing one, but in this case we encountered the following 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. "
Then we made a lookup field and populated all the recods with value in that field and then tried converting it to Master-Detail Relation but again encountered the first error message..
"There were custom validation error(s) encountered while saving the affected record(s). The first validation error encountered was "Generic Exception Creator".
 
We have also deleted all the reports which use that lookup Field but still were'nt able to change it to Master Detail Relation
If any one has any knowledge regarding the same, Please do let us know.
 
Thanks in Advance,
Bharat.
 
Best Answer chosen by Admin (Salesforce Developers) 
Vijay RautVijay Raut

Hi,

 

I think, i have got the reason for above problem. If the field (whose type we are changing) referred somewhere in Apex Code (Apex Class, Apex Trigger,....)  then while changing field type, it shows mentioned error.

 

WorkArround - Investigate Apex Code where field is referred and try to comment out (temporary) referrence to the field. Once field type changed, roll back apex code. During this, make sure it is not impacting anyting else.

 

Cheers,

V.R.

 

 

All Answers

RasmiRasmi

Hi Iam also facing the same problem.

If any one can find a solution,Please inform.

 

 

Regards,

Rasmi

Wipro

Vijay RautVijay Raut

Hi Bharat, Rasmi,

 

I am also having same issue (only change is i am trying to convert Text Field to Picklist field). Have you able to get any workaround / reason for above problem.

 

Thanks in advance.

 

Cheers,

V.R.

Vijay RautVijay Raut

Hi,

 

I think, i have got the reason for above problem. If the field (whose type we are changing) referred somewhere in Apex Code (Apex Class, Apex Trigger,....)  then while changing field type, it shows mentioned error.

 

WorkArround - Investigate Apex Code where field is referred and try to comment out (temporary) referrence to the field. Once field type changed, roll back apex code. During this, make sure it is not impacting anyting else.

 

Cheers,

V.R.

 

 

This was selected as the best answer
dmchengdmcheng

This can also occur if you have orphaned child records, i.e. the lookup field has no value.  You have to delete the orphaned records before you can change the field type to master-detail.

 

David

mullamurimullamuri

goto setup--> App setup-->create-->object-->objectname-->field(wat u wnt change fieldname)edit--->select(masterdetail--->next---->next--->next-->save) this is the process of look up relation to master detial if one object  2 times only master details  existing