You need to sign in to do that
Don't have an account?

If i change field
Below code is to autopopulate the fields from Contact to Oppertunity.
If i change any field value in Opportunity record it should update in Opportunity as well as in Contact
For this i need to proceed with event after update.Can u plz guide me how to proceed with after update event
List<Opportunity> newOpps = new List<Opportunity>();
for (Contact con : Trigger.new) {
Opportunity opp = new Opportunity();
opp.Name = con.LastName+' Opportunity';
opp.StageName = 'Prospecting';
opp.Status__c = con.Status__c;
opp.version__c = con.version__c;
opp.CloseDate = Date.today() + 90;
// opp.AccountId = acc.Id; // Use the trigger record's ID
newOpps.add(opp);
}
if(newOpps.size()>0)
insert newOpps;
}
List<Opportunity> newOpps = new List<Opportunity>();
for (Contact con : Trigger.new) {
Opportunity opp = new Opportunity();
opp.Name = con.LastName+' Opportunity';
opp.StageName = 'Prospecting';
opp.Status__c = con.Status__c;
opp.version__c = con.version__c;
opp.CloseDate = Date.today() + 90;
// opp.AccountId = acc.Id; // Use the trigger record's ID
newOpps.add(opp);
}
if(newOpps.size()>0)
insert newOpps;
}
If i change any field value in Opportunity record it should update in Opportunity as well as in Contact
For this i need to proceed with event after update.Can u plz guide me how to proceed with after update event
List<Opportunity> newOpps = new List<Opportunity>();
for (Contact con : Trigger.new) {
Opportunity opp = new Opportunity();
opp.Name = con.LastName+' Opportunity';
opp.StageName = 'Prospecting';
opp.Status__c = con.Status__c;
opp.version__c = con.version__c;
opp.CloseDate = Date.today() + 90;
// opp.AccountId = acc.Id; // Use the trigger record's ID
newOpps.add(opp);
}
if(newOpps.size()>0)
insert newOpps;
}
List<Opportunity> newOpps = new List<Opportunity>();
for (Contact con : Trigger.new) {
Opportunity opp = new Opportunity();
opp.Name = con.LastName+' Opportunity';
opp.StageName = 'Prospecting';
opp.Status__c = con.Status__c;
opp.version__c = con.version__c;
opp.CloseDate = Date.today() + 90;
// opp.AccountId = acc.Id; // Use the trigger record's ID
newOpps.add(opp);
}
if(newOpps.size()>0)
insert newOpps;
}
try comparing the old values with new vlaues of the record.
OR
Let me know, for more info.