+ Start a Discussion
Rachel JonesRachel Jones 

Auto Add Invitees to Event

Hi - I have a custom object, 'Jobs', and when the job status is set to 'scheduled' I have a Process Flow to create the 'Install Event'.  I can map over the job - event fields with no issue, however I have 'Lead Engineer' as a look up contact field on the job and would like to auto add this contact as an invitee to the event.  There is an option in the process builder to set the contact as 'IsInvitee = TRUE' but that does not seem to do anything - I assume because there doesn't seem to be a way of identifying the specific event.  

I am hoping to have a solution to this without coding as I am not a coder and we are on a very limited budget.  any help here would be much appreciated.  Thank you for taking the time to read!
Rachel JonesRachel Jones
Spoke with SFDC who confirm that this is only possible in apex code :-( so looking for another solution/process.
Jayson Faderanga 14Jayson Faderanga 14
Hi Rachel,

try this one. :)

trigger autoAddInvitees on Event (after insert) {

//bulkify incomingEvents
List<Event> nEvent = trigger.new;
List<EventRelation> iErelation = new List<Eventrelation>();

//send update to invitees
Database.DMLOptions dmo = new Database.DMLOptions(); 
dmo.EmailHeader.triggerUserEmail = true; 

//loop on bulkfiedEvent
for(Event lEvent : nEvent){
    if(lEvent.IsGroupEvent == false){
 EventRelation er = new EventRelation();
    er.EventId = lEvent.Id;
    er.RelationId = '00528000000q1QV';

Database.insert(iErelation, dmo);


hope that helps.. that fixes the problem of sending an alert to all your invitees