You need to sign in to do that
Don't have an account?
How can I trigger an event date to auto populate an oppportunity custom field?
I am new to Apex Coding / Triggers and I am stuck. I'm trying to create a trigger where when an event is created with a specific subject line, it automatically populates an "Appointment Date" custom field on the Opportunity object. Where do I begin? Thank you!
please like and mark this as solution if this solves you problem.
PS: if this answers your question then hit Like and mark it as solution!
List<String> subject = new list<string>();
map<string,date> dates = new map<string,date>();
for(event e : trigger.new)
{
subject.add(e.subject);
dates.put(e.subject,e.appointment_date__c);---------->replace appointment_date__c with the date you want to copy in event object
}
//get the list of opps based on the subject field
list<opportunity> opp = [SELECT Id,Name From Opportunity Where Name in : subject];
for(opportunity o : opp)
{
o.Appointment_date__c = dates.get(o.name);----------------------->replace appointment_date__c with the field in opportunity object.
}
update opp;
}
Can you describe this to me?