You need to sign in to do that
Don't have an account?
Vishy
Trigger to update actual completion date from Opportunity field to field in Plot object
Hi sorry if this is in the wrong place but i am struggling to create a trigger that will automaticially add the date entered in Actual_Completion_Date__c on the Opportunity object to one (Actual_Completion_Date__c) in the plot object. I have created a look up field in the plot object called Opportunity_Link as i was unable to fill the date field using formulas and different field types.
Hello, I think this should work for you,
trigger insertDate on Plot__c (before insert)
{
Set<id> objSet = new Set<id>();
for(Plot__c objPlot: Trigger.new)
{
objSet.add(objPlot.Opportunity_Link__c);
}
List<Opportunity> lstOpp = [select id, Actual_Completion_Date__c from Opportunity where Id in: objSet];
for(Plot__c objPlot: Trigger.new)
{
for(Opportunity objOpp: lstOpp)
{
if(objPlot.Opportunity_Link__c == objOpp.Id)
{
objPlot.Actual_Completion_Date__c = objOpp.Actual_Completion_Date__c;
}
}
}
}
-Sunil
Hi Sunil thanks for your reply. I am getting this error when i try to save the trigger:
Any ideas?
You have to right trigger on your custom object not on opportunity. I am taking it as Plot__c. Write trigger on, whatever your custom object name is.
This is the only problem, trigger is working fine.
- Sunil