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
Kr ramKr ram 

Master-detail object in same page


I have a master object- Parentobj1

Detail child obj-childobj1 in a master detail relationship


When i create a NEW Record using the the NEW button in the  Parentobj1,i want to add the childobj1 fields in the EDIT page of the 

Parentobj1 ,itself


Currently the process  is to create the parentobj1 record using the NEW button  and Save It and then NAVIGATE to the child Related list click new enter and save it,


I know a a VF page can accomplish it but i want a simple solution.

any thoughts?


you can do with the help of trigger,
trigger triggerName on Parent__c(after insert){
//prevent error when bulk records r inserted;
Set<Id> parentIds = Trigger.New[].KeySet();
List<Parent__c> parents = [Select Id from Parent__c where Id in :parentIds];
List<Child__c> childObjs = new List<Child__c>();
for(Parent__c pP : parents){
childObjs.add(new Child__c(Name = 'dummy', parentObj__c = pP.Id ));
insert childObjs;
this trigger will create dummy child with preset field values for each and every parent.
So on detail page of parent, already related list will contain with child record.

hope this will help you.
Kr ramKr ram

I need the users to enter the related child object NOT an auto insert by a trigger so requiring a solution when the user clicks NEW and able to enter the parent and child object fields in one single page.

Kr ramKr ram

HI Any thoughts? on this would be nice,thanx!