I created a custom object which when saved creates a calendar Event using an Apex trigger. Am able to populate all of the desired fields in the Event except the Related To field. I want the Related To Object to inherent the custom object name and the Related To field the customer object record name.
Thanks!
> trigger calup on Schedule_Onsite_Technician__c (after insert, after
> update) { List<Event> NewFSEvent = new List<Event>();
>
> for (Schedule_Onsite_Technician__c eve : Trigger.new) {
> Event e = new Event();
> e.StartDateTime = eve.Onsite_Arrival_date_Time__c;
> e.EndDateTime = eve.Return_date__c;
> e.Location = eve.Location_Address__c;
> e.Description = eve.Equipment__c;
> e.OwnerId = eve.Assigned_Tech__c;
> //e.WhatId = eve.RecordID;
> //e.What.Type = 'ScheduleOnsiteTechnician';
> e.ShowAs = 'OutofOffice';
> e.Subject = eve.Field_Service_Activities__c;
> e.WhoId = eve.Contact__c;
>
> NewFSEvent.add(e); }
>
> insert NewFSEvent; }
eve.recordid
should beeve.id
. You don't need to setwhat.type
.