+ Start a Discussion
Sfdc SivaSfdc Siva 

Writing Trigger help

Hi All,

We have one Formula field called "Contract End Date"  in Opportunity object ,Needs  to populate the "Contract End Date" on the Account "Service Contract End Date"  at the time of opp is created.

Can any one please help me to creating a trigger on above senario.

trigger triggername on Opportunity(after insert, after update){
        list<ID> lstid = new list<ID>();
        list<Account> lstacc = new list<Account>();
        for(Opportunity opp: trigger.new){
        for(Account acc : [select id, ContractEndDate__c from Account where ID IN: lstid]){
            for(Opportunity co : trigger.new){
                acc.ServiceContractEndDate__c = co.ContractEndDate__c ;
        upsert lstacc;