pic2

This has been an ambiguous field for many Salesforce Customers, Developers and Admins alike since ages and till date people are ambiguous about what value exactly goes into the LastActivityDate in the Account object. The most common misconception is that LastActivityDate holds the date when the last activity record associated to the account was added/modified. However, the reality is far different. The field actually holds either of the below values.

  • Due date of the most recent event logged against the record.
  • Due date of the most recently closed task associated with the record.

This is where people call the field deceptive. However, if we didn’t know this then it’s because we as human beings tend to assume things and Salesforce has clearly mentioned in their documentation about what value goes into their respective fields in the schema and the reality here is that we just never bothered to look at it. Below is the link to a knowledge article from Salesforce which explains the difference between the Last Activity and Last Modified.

https://help.salesforce.com/articleView?id=What-is-the-difference-between-Last-Activity-and-Last-Modified-1327108315155&language=en_US&type=1

I have burned my hands in the past when dealing with this field and thought of sharing this so that at least someone who has read this post doesn’t fall into the same deathtrap !

So now let’s see how do we figure out to build a field which will actually hold the value that you were looking for – the date when the last activity record was added to an Account. It’s actually a cakewalk to do this using the Process Builder. Well, it wasn’t this easy sometime back to build the same stuff wherein you had to use a combination of process builder and flows if you wanted to fetch the Last Date when an activity record was added to any of the objects (Custom or Standard). We no longer have to go down the path of flows to do this, all thanks to Salesforce for coming up with an improved version of process builder with every new release (Yeah, it keeps getting stronger). Now, let’s get down to the implementation part. The approach mentioned here can be followed for any of the objects in Salesforce, be it Custom or Standard with the exception of Contacts and Leads.

Steps

Create a custom datetime field on the Account called as LastActivityLoggedOn. A datetime field is more preferable over a date field, because it even allows us to capture the time when the activity was logged which becomes crucial for many businesses.

Go to Setup > Process Builder and set up the process as seen in the screenshot below

l1

The process I have configured here is to capture the time when the activity was added and not when it was modified. If you want to capture the time when the associated activity record was last modified, then you need to select the second checkbox in the below screenshot.

l2

The next step is to select a criteria for the process. However, we simply want to capture all the activity records that are added, so the process won’t have any criteria !

l8

The action for the process can be configured as seen below

l4

Simply select the Related to ID (Account) in the object to be updated.

l5

Finally the LastActivityLoggedOn field can be assigned a formula value of NOW() as seen below.

l6

That’s it. Simply Activate your workflow and you are good to go. Henceforth as and when a new activity record is added to Account, the LastActivityLoggedOn field would be populated with the appropriate value.

Feel free to comment on this post if you have any question or issues.

 

 

Advertisements