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
Vinay KolusuVinay Kolusu 

Force.com Workbook

hi All, i am trying to complete the force.com workbook and as a part of the execution of the steps, i came across the following error. Request inputs on how to resolve this .

WorkBook step :: Update Total Inventory When an Order is Placed

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. 

 
JustAGirlyGeekJustAGirlyGeek
Hello Vinay,

The error is telling you that there are some records that do not have a value in the lookup field you would like to convert to a master-detail field. Once you've filled in a value for each of those records that do not have a value in the lookup field, you will be able to change the lookup field type to a master-detail relationship field.
Vinay KolusuVinay Kolusu
Hi, Thanks for the reply. I had done the following steps

1, Deleted all the records for the object in question i.e., Merchandise 
2. Tried changing the Field type to Master-Detail relationship, 

however, i am still facing the same. 

As per your reply, the problem should be present if there are any records in the Objects , however the absence of records should make the change of field type to succesfull. 

Please correct me if my understanding wrong.

Thanks,
Vinay
JustAGirlyGeekJustAGirlyGeek
I just took a look at the Force.com workbook. It looks like the Merchandise field is on the 'Line Item' object. All 'Line Item' records must have a value in the Merchandise field before you can change the field type; otherwise you would just need to delete all 'Line Item' records before you can make the change to field type. You will need values in the Merchandise object to relate to the Line Item record(s). Hope this helps.