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

how to populate values from parent record to child record if object is same

I need to popluate values from parent record to child record using trigger if the object is same ,
Suppose in Account object(choose Record Type A) i have created and now i am going to create another record(let say child account record) in Account object but this time i have choose the Record Type B
So while i am creating child record some fields need to copy from first account record to child account record [i have created self relationship here]

below is the code 

Trigger PopulatevaluesonChildAccount on Account(Before Insert)
    Set<Id> ParentIds = New Set<Id>();

   For(Account A : Trigger.New)

   List<Account> ParentList = [Select Id,AccountType__c,name from Account where Id =: ParentIds];
   For(Account ChildAccount : Trigger.New)
        For(Account ParentAccount : ParentList)
            IF(ChildAccount.AccountType__c == ParentAccount.ID)
                IF(ParentAccount.Name != NULL)
                    ChildAccount.Name = ParentAccount.Name ;

Can someone please help on that  
AnkaiahAnkaiah (Salesforce Developers) 

What are all the fields you need to copy from parent record and provide the self lookup relationship field name.