+ Start a Discussion
Debaranjan GhoshDebaranjan Ghosh 

master detail screen in visual force

Want to Create a Master Detail Screen in Visual force Page where we will input
Master field and based on that either by pressing enter or clicking a button 
it will show list of Maching Record which can be edited and saved 
Can you please guide me how to achieve this using Custom Controller and VFP 
PriyaPriya (Salesforce Developers) 

The developer community recommends providing any attempts/code you've started, any errors you're getting, or where exactly you're struggling in achieving this while posting a question.


 
Debaranjan GhoshDebaranjan Ghosh
Hello Priya

Thanks for your previous reply


I am trying to Make a custom Object and its fields using Following codes :
And I am facing some problems with them

1> Code for creating Custom Object : This created the Object but it is not visible from my Object Manager. How ever I can see it from Work bench Queries and VS Code Object Browser and also can query it from Dev Console --> Query editor

2> Code for Creating Custom fields : This piece of code when executed from Workbench/Dev Console Anonymous window completes and logs show sucess and No error However I dont see the fields got created by the code

Can you please help me to fix this Issue :

1> Code for Creating the Object :
============================
MetadataService.MetadataPort service = new MetadataService.MetadataPort();  
service.SessionHeader = new MetadataService.SessionHeader_element();
service.SessionHeader.sessionId = UserInfo.getSessionId();
//system.debug('session id:'+UserInfo.getSessionId());
System.debug(UserInfo.getOrganizationId()+''+UserInfo.getSessionId().SubString(15));

List<MetadataService.Metadata> fields = new List<MetadataService.Metadata>();
MetadataService.CustomObject  customobject = new MetadataService.CustomObject();
customobject.fullName = 'Book__c';
customobject.label = 'Custom created object';
customobject.pluralLabel = 'Custom created objects';
customObject.nameField = new MetadataService.CustomField();
customobject.nameField.type_x = 'Text';
customobject.nameField.label = 'Custom created field';
customobject.nameField.api = 'Title__c';
customobject.deploymentStatus = 'Deployed';
customObject.sharingModel = 'ReadWrite';
fields.add(customobject);

MetadataService.SaveResult[] results = service.createMetadata(fields);


2> Code to Create the fields
======================
MetadataService.MetadataPort service = new MetadataService.MetadataPort();  
service.SessionHeader = new MetadataService.SessionHeader_element();
service.SessionHeader.sessionId = UserInfo.getSessionId();

List<MetadataService.Metadata> fields = new List<MetadataService.Metadata>();
MetadataService.CustomField customField = new MetadataService.CustomField();
customField.fullName = 'Book__c.Title__c';
customField.label = 'Title';
customField.type_x = 'Text';
//customField.deploymentStatus = 'Deployed';
//customField.sharingModel = 'ReadWrite';
fields.add(customField);

MetadataService.CustomField customField1 = new MetadataService.CustomField();
customField1.fullName = 'Book__c.Author__c';
customField1.label = 'Author';
customField1.type_x = 'Text';
fields.add(customField1);

MetadataService.CustomField customField2 = new MetadataService.CustomField();
customField2.fullName = 'Book__c.ISBN__c';
customField2.label = 'ISBN';
customField2.type_x = 'Text';
fields.add(customField2);

MetadataService.CustomField customField3 = new MetadataService.CustomField();
customField3.fullName = 'Book__c.Publisher__c';
customField3.label = 'Publisher';
customField3.type_x = 'Text';
fields.add(customField3);

MetadataService.CustomField customField4 = new MetadataService.CustomField();
customField4.fullName = 'Book__c.Price__c';
customField4.label = 'Price';
customField4.type_x = 'Text';
fields.add(customField4);

MetadataService.SaveResult[] results = service.createMetadata(fields);