Gurus, I'm creating a MasterDetail field in the child object with the following code:
Schema.DescribeSObjectResult parentObj = Schema.getGlobalDescribe().get('account').getDescribe();
MetadataService.CustomField bdpoField = new MetadataService.CustomField();
bdpoField.fullName = 'Bank__c.Parent__c';
bdpoField.externalId = false;
bdpoField.label = parentObj.getLabel();
bdpoField.referenceTo = parentObj.getName();
bdpoField.relationshipLabel = parentObj.getLabel();
bdpoField.relationshipName = 'BankParent';
bdpoField.relationshipOrder = 0;
bdpoField.type_x = 'MasterDetail';
bdpoField.writeRequiresMasterRead = false;
List<MetadataService.SaveResult> saveResults = service.createMetadata(
new MetadataService.Metadata[] { bdpoField }
);
handleSaveResults(saveResults[0]);
But when I go to the parent object - in this case Account object-, I cannot find this child object in the related list options on Edit Layout. Anybody has been with the same trouble? How to solve this?