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
NandhuNandhu 

I want to create an fullname on opportunity autopopulates as related list of account of using field fristname ,lastname using trigger

trigger TriggerFullNameExample on Opportunity (before insert) 
{   
    List<Account> acc=new List<Account>();
    for(Opportunity opp:trigger.new) 
{    
    if(acc.First_Name__c + '' + acc.Last_Name__c==opp.FullName__c)
    {
        Account acco= new Account();
        acco.First_Name__c+ '' + acco.Last_Name__c== opp.FullName__c;
        acc.add(acco);
    }
}
    insert acc;
}
NandhuNandhu
Tell whether my program is correct or wrong .
please let me know any suggestion for it
Akash KainturaAkash Kaintura

do  FullName__c, First_Name__c , Last_Name__ccustom field exists in the Opportunity field?

 

NandhuNandhu
Yes
NandhuNandhu
No, 
FirstName,LastName are custom field of Account.
FullName is the custom field of opportunity
when you back to opportunity, you must see the firstname,lastname of account  must combine as the fullname  field display on the opportunity in the lookup.but you must use the trigger.
Ex account field : First_Name__c : Santhi
     Last_Name__c:: Patil
Now on opportunity must be display as fullName :Santhi patil in the lookup