Last “Key” Activity Date

Have you noticed that Salesforce’s Last Activity Date is not very useful?  It could have been triggered by a number of activities, but not always the ones that matter.  Think of this Flow as a blueprint for any type of activity you would like to track.

Imagine a stakeholder asks you, “Can I have a Last Activity Date for only completed Demos on an Account?  We want to be able to easily report and track the Accounts we are Demoing on.”  Lets assume for the purpose of this example that every Demo preformed is as a Task on an Opportunity.  Every time a someone completes a Demo, they must select what type of Demo was preformed via the Custom Picklist Field Demo Type.

Create a Custom Date Field on the Account.  Label the Custom Field Last Demo Date. (Setup | Customize | Accounts | Fields)

Create a New Flow.  (Setup | Create | Workflows & Approvals | Flows)

For this Flow we need to create two Text Variables and one Date Variable.  Call the variables AccountId and OpportunityId, and ActivityDate

OpportunityId

AccountId

ActivityDate

Create a Record Lookup to Find the AccountId from the Opportunity.

Record Lookup

Create a Record Update to Update Last Demo Date 

Record Update

Set the Start Element for the Flow

Set Flow to Start

Save the Flow, label it Update Last Demo Date.  And then Activate the Flow.

Save Flow

For this Flow we are assuming that the Opportunity is always the WhatId, as that is what the Sales team has been trained to use when tracking their Demos.  We use a Process Builder to trigger on all Completed Activities that are Demos.  If the criteria was met, we will then have the Process Builder fire off the Autolaunched Flow Update Last Demo Date.

Create a New Process Builder and have it based on the Task Object.

Process Builder on a Task

Have the Filter Criteria be when a Demo has been completed.  In this case, we want to have it being when a Demo Type is entered and the Task is completed.

Now we get to setup the Autolaunched Flow to fire off the Last Demo Date update.  Then, set the Flow Variables for ActivityDate and the OpportunityId.

Automated Flow Setup

Hit Save and then Activate the Process Builder!  Congrats, you’re done!  Now test the Autolaunched Flow to make sure everything is working properly.

4 thoughts on “Last “Key” Activity Date

  1. Jeremy February 15, 2016 / 10:02 pm

    Thank you for sharing this.

    I implemented this flow to update a field on the Contact object called Last Activity Date with the due date of the most recently completed Activity. However, when my colleague conducted an import of about 170 tasks, it prevented him and produced an error for each task imported. I can’t figure out what went wrong.

    The error was:

    ERROR: The record couldn’t be saved because it failed to trigger a flow. A flow trigger failed to execute the flow with version ID 301o00000008t1J. Contact your administrator for help.

    I simultaneously received 2 flow error email. The first error email was:
    An error occurred at element Update_Last_Activity_Date (FlowRecordUpdate).
    UPDATE — UPDATE FAILED — ERRORS : (ALL_OR_NONE_OPERATION_ROLLED_BACK) Record rolled back because not all records were valid and the request was using AllOrNone header — for SFDC record with ID : {here it had each contact ID for each error}.

    The second error email was:
    An error occurred at element myRule_1_A1 (FlowActionCall).
    This report lists the elements that the flow interview executed. The report is a beta feature.
    We welcome your feedback on IdeaExchange.
    Flow Details
    Flow Name: Update_Last_Activity_Date_on_Contact
    Type: Workflow
    Version: 1
    Status: Active
    Flow Interview Details
    Interview Label:
    Current User: Dave Bailey (005o0000000W5CJ)
    Start time: 2/15/2016 5:53 AM
    Duration: 22 seconds
    How the Interview Started
    Dave Bailey (005o0000000W5CJ) started the flow interview.
    Some of this flow’s variables were set when the interview started.
    myVariable_old = null
    myVariable_current = 00To000000q5NpyEAE
    ASSIGNMENT: myVariable_waitStartTimeAssignment
    {!myVariable_waitStartTimeVariable} Equals {!Flow.CurrentDateTime}
    Result
    {!myVariable_waitStartTimeVariable} = “2/15/2016 5:53 AM”
    DECISION: myDecision
    Executed this outcome: myRule_1
    Outcome conditions: and
    1. {!formula_myRule_1} (true) Equals true
    Logic: All conditions must be true (AND)
    UPDATE_LAST_ACTIVITY_DATE (FLOWS): myRule_1_A1
    Inputs:
    ActivityDate = {!myVariable_current.ActivityDate} (February 3, 2016)
    ContactID = {!myVariable_current.WhoId} (003o000000ePXEMAA4)

    Like

    • David Litton February 15, 2016 / 10:14 pm

      So, the importing of the Tasks caused the main error. This Flow is not meant to work on a data load, as Flow isn’t really bulkified to that point yet. So, that was really the only issue it would seem based on your “all or none” error. I would recommend turning the Process Builder off and trying again. If you want the Last Date to update, then you need to do that with a separate data load. However, since you’re dealing with the data in Excel already, that shouldn’t be a big issue. Just remember to turn the Process Builder back on once you’re done

      Like

  2. Tim Andrews December 9, 2016 / 6:39 pm

    I have a somewhat similar use case that I’m having trouble with.

    How can I find and use the date of the most recent activity performed by a specific user on a person account?

    Here is my use case: We have salespeople assigned to person accounts via a custom field called “Contact Center Owner” (lookup to User object). Our business rule is that the Contact Center Owner must have some sort of contact with the person account (task, event, log a call, email, etc) every 30 days or they lose ownership and can’t claim commission for subsequent sales to the person account. I am trying to create a “stoplight” function to show if the Contact Center Owner has had an activity within the last 30 days or not. I’m getting hung up when identifying whether any activity performed by the Contact Center Owner falls within the last 30 days.

    Help?

    Like

    • David Litton December 12, 2016 / 4:40 am

      Tim, I would just throw on a filter in the Process Builder to only run on that type of User. And, you can create a “Contact Center Last Activity Date” field that you update if you want it to be a bit more clear. Just make sure you check for null on the User before accessing fields inside of the User creating the record. Then, you can run your stoplight off of that formula field.

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s