You need to sign in to do that
Don't have an account?
Help for trigger
Hi All,
Appreciate if you could help me correct this trigger
When a custom lookup field on opportunity(Contract__c) is updated then some fields from Contract standard object should autofill the fields on opportunity.
trigger UpdateOpportunity on Opportunity (after insert, after update) {
//List opportunity to insert, update
List<opportunity> insertOPList= new List<Opportunity>();
List<opportunity> updateOPList= new List<Opportunity>();
for(Contract co:trigger.new){
//check for the contract lookup on Opprtuinty
if(trigger.isinsert && trigger.isafter && OP.Contract__c==true){
OP.add(new pportunity(Contract_Start_Date__c=co.Contract_Start_Date__c, Contract_End_Date__c=co.Contract_End_Date__c));
}
//check for the contract lookup update on Opprtuinty
if(trigger.isupdate && trigger.isafter && OP.Contract__c==true){
OP.add(new pportunity(Contract_Start_Date__c=co.Contract_Start_Date__c, Contract_End_Date__c=co.Contract_End_Date__c));
}
}
insert insertOPList;
update updateOPList;
}
}
Hi,
Try this
Imran,
Thank you for the reply and i really appreciate your help... can you please check these line again...
Contract is a standard object and Contract__c is a custom lookup field on opportunity. When this custom lookup is updated with some contract record then some fields from that contract record should auto fill the fields in Opportunity. Just for instance I gave some standard fields in Contract(StartDate and EndDate) which autofill into Opportunity custom fields(Contract_Start_Date__c and Contract_End_Date__c). Please help me with this.. Thanks.!!