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
rob_burkettrob_burkett 

Need Last Activity Date by Activity Type

Need Last Activity Date by Activity Type

I'm trying to figure out how to display a particular type of activity using the LastActivityDate functionality built into salesforce.

 

Here's the situation:

  • We track all reference calls and surrounding activity within a custom object called "Customer Stories" which is a free app from Salesforce.
  • We created an activity type called "Reference Call"
  • We added a formula field called "Last Reference Date" on Customer Stories
  • Currently we have last reference date = LastActivityDate, which would work if we only used activities to track reference calls. 
  • However we want to use activities to track all the work surrounding references, including qualifying references (both internally and externally) as well as tracking what gift cards were sent out, etc.  So now the "LastActivityDate" isn't very helpful. 

 

Is there anyway to pull LastActivityDate for activities with "Reference Call" as the activity type?

 

Any help would be appreciated.

 

Thanks!

Rob



grigri9grigri9

I don't think you can leverage the lastactivitydate functionality to do this. The easiest way is with a trigger on the object. Something like this:

 

 

list<Account> AccsToUpdate = new list<Account>();

for(Task t : trigger.new)
{
  if(t.whatid.startswith('001') && t.type == 'Reference Call')
  {
    AccsToUpdate.add(new Account(id=t.whatid,last_reference_call__c=t.activitydate));
  }
}

if(AccsToUpdate.IsEmpty()==false) update AccsToUpdate;