function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
DeptonDepton 

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!

 

 

 

 

 

dmchengdmcheng

what error are you getting?