+ Start a Discussion
steve456steve456 

Auto Events Creation-----Very Urgent

Whenever a custom object record is created an event is created on the calendar

 

Custom Object Name is Building

 

Here  is the trigger

 

trigger AutoEvent on Building__c(before insert) {

  List<Event> lstNewEvents = new List<Event>();

  for (Building__c bul : Trigger.new) {
    Event e = new Event();
    e.StartDateTime = bul.Start_Date__c;
    e.EndDateTime = bul.End_Date__c;
    e.Subject = bul.Building_Event_Type__c;
    e.Phone__c=eve.Phone__c;
    e.Email__c=eve.Email__c;
    e.WhatId=------------------;I want this to be to given to the building name .How can i
    e.WhoId = ------------;     Whom should i refer to can i give it to the owner
    lstNewEvents.add(e);
    }
  }

  insert lstNewEvents;

}


Is there any possibility that is event on calendar can be created to multiple invitees at the same time

ritika@developerforceritika@developerforce

Hi,

 

In case you wish to add Multiple Attendees (Invitees), use the EventAttendee standard object. You can add mulitple event attendees to one event. For the What Id, Use the Building Id (which will not be available in a Before Trigger)

 

Hope this Helps

 

Regards,

Ritika

craigmhcraigmh

Yeah, you definitely need to change this to an after insert trigger.

Dirk GronertDirk Gronert

It is not possible to create multy attendee events from apex!!

 

http://success.salesforce.com/ideaView?id=08730000000BrDkAAK 

 

Please vote for this feature if this should be become standard!

 

Cheers,

 

--dirk

steve456steve456

why is it not possible

 

i would repeat the  for loop for specific persons i want,....

 

 

Can you explan with more clarity

 

 

 

 

Dirk GronertDirk Gronert
The reason is simple: multi attendee is only available with the help of the standard UI! The attendee object in the data model is not createable - check that out with workbench, eclipse or force.com explorer. So there is no way to create an attendee record usind the api / apex!

Would mean you can loop over the person account records - but how you will assign the records to only one event when the attendee record is not creatable, you can only have one whatid and whoid and you can not create a junction obj with a lookup to tasks/activities?! ;-)

Cheers,

--dirk


steve456steve456

I would  created 5 individual events to 5 different ppl with same data

 

When you click save

 

it would create events with same name and all info but is present on thier own calendars

 

 

All i doubt is how do i write a test method when it is read only

Dirk GronertDirk Gronert
OK - now you create events for each people ...

Do you know the person accounts to assign to when your object is created?! If yes than just create some records of your custom object within your test methd - the trigger will generate the events and than just query for the events and count them - now compare the count to the expected size and assert! Done!

Cheers,
--dirk

Dirk GronertDirk Gronert
BTW: what do you mean with read-only?!
steve456steve456

you told event attendee obj is read only right

Dirk GronertDirk Gronert
In your case - creating multi record events - you are fine!!

The attendee obj is only used when you create one event record and assign that record to more than one attendees! This is only possible by usind the standard ui! So you have no access to this via api!

Would mean with your approach you can just write your test classes and deploy it!

In case all works pls mark the thread as solved!

Thx and good luck!

--dirk
steve456steve456

Fingers crossed....i donno yet..i am wrkng if it would thn deal done