• Mouse Liu
  • NEWBIE
  • 0 Points
  • Member since 2012

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies

I wanted to build a simple trigger on the Event that would make a checkbox true if the What field looked up to one of our custom objects, and false otherwise. But with my attempt at this, it keeps making the checkbox true regardless of what is related to the event and I don't understand why. Here's the code:

 

trigger WorkOrderCheckbox on Event (before insert, before update) {
 for(Event newEvent : trigger.new) {
  if(newEvent.What instanceof SVMXC__Service_Order__c) {
   newEvent.Work_Order__c = true;
  } else {
   newEvent.Work_Order__c = false;
  }
 }
}

What am I doing wrong here?