+ Start a Discussion

Populating "assigned to" and "type" (event standard fields) in trigger

I am just writing a basic trigger and I'd like to change the related to field, and populate the event type field.


trigger Event on Web__c (after insert) {     
List<Event> ev = new List<Event>();
    for (Web__C newWeb: Trigger.New)
         if (newWeb.Name !='1'){
                 ev.add (new Event(
                     Subject = newWeb.Name,
                     WhoId= newWeb.Trainer__c,
                     WhatId = newWeb.id,
                     StartDateTime= newWeb.Web_Start_Date__c,
                     EndDateTime= newWeb.Web_End_Date__c));   
   insert ev;

 Y tried without success


Owner(related to)= newWeb.Ownerid

Type = 'Web' (Web is one of the event picklist values and has no relaed field in the Web object)


Any ideas??


Thank you!







what error are you getting?