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
anil87anil87 

Trigger on Task

Hi Everyone,

 

I have a trigger (statuschanges) running right now that updates a custom field on the lead "LastCallResult__c" with the CallResult/CallDisposition from the call activity.(Tasl Object)

 

Now that we'll be using Opportunity, Acct, Contact, etc... We will need this trigger updated based on the WhoId/WhatID on the Activity.
 
Any help appreciated greatly.
Jeff MayJeff May

You can check the Task WhoId/WhatId to determine the Object type by looking at the first 3 characters.

 

Here is a reference URL:  http://salesforce.madhanraja.com/standard-salesforce-object-prefixes/

 

 

sfdcfoxsfdcfox

@JeffM, that's so last year:

 

for( task t: trigger.new ) {
  if( t.whoid != null && t.whoid.getsobjecttype() == contact.sobjecttype ) {
    // it is a contact
  }
}

 

Jeff MayJeff May

I am nothing if not fashionably behind the times.  Thanks for the update.  I have some code to go (re)write.  :)