Counting Tasks with DLRS

      22 Comments on Counting Tasks with DLRS

ObHow many tasks have been done in X time frame is a common ask from marketing or sales.  Before it would require a report to answer but now with DLRS we can have that answer live on the record itself.  In this example I’ll go over Task Counting for Leads.

The theoretical ask this DLRS can solve for is this.  Someone would love to know how many tasks in the last week have been done on a Lead.   Even better they would love to get a quick count of how many tasks are on that Lead that are not from some sort of automated system.  Well with DLRS you can accomplish that pretty easily.  The goal is so an SDR can create a List View that only pulls in leads that have not been contacted by a person more than 2 times in the last week.

First step is on the Lead lets create a numeric field and name it Completed Tasks In The Last Week.  Lets make the API name of the field DLRS_Completed_Tasks_In_The_Last_Week.  Next lets go and create our DLRS.  I’ll use the Custom Metadata layout as that seems to be the new hotness and most likely the future of DLRS.

  1.  This is the Parent Object as we want to roll the count up to the Lead Record
  2. Activities/Task live on the Task Object
  3. WhoID is the field that relates Tasks/Activities to the Lead Object.  It is a strange field here is a data map of it
  4.   This is where all of our business logic will live.  We will go through these step by step for this use case.
    1. For this use case we only want to select Tasks that have been completed.  So we say that IsClosed must be TRUE.
    2. We also don’t want to count ones that our Marketing Automation system creates automatically but WE DO want to count those that are created when a rep sends an email through in this case Marketo Sales Insight.  So we know that when a Rep creates a task via MSI Marketo creates it but ASSIGNS it to the Rep.  When Marketo creates a Task from a marketing email or activity it assigns the task to itself.  In this case the Assigned To field is OwnerID so we say that the OwnerID is NOT EQUAL to the ID of our Marketo user.
    3. We don’t want to count things that were set as complete further in the past then last week so we say ActivityDate >= LAST_WEEK.  We also don’t want to count things in the future where someone might have entered in the wrong value so we use ActivityDate <= TODAY.  We also don’t want to count things where there was no Date filled in so you can’t see it in the screenshot but there is ActivityDate != Null also.  (If you wanted to get fancy you could set up a workflow rule to stamp the date when an activity is completed and use that as your criteria so you could have people leave the due date in the future to show they completed something early).
    4. When we put it all together the field ends up reading as so
      IsClosed = TRUE AND OwnerId != ‘a145000000CDmlQ’ AND ActivityDate >= LAST_WEEK AND ActivityDate <= TODAY AND ActivityDate != Null
  5. This is where we put in all of the fields we use in #4 on separate lines, in this case IsClosed, ActivityDate and OwnerID
  6. We just want a count of the records so we just can put ID here and it will count how many ID’s are returned.
  7. We want to Count how many records are found
  8. This is where we want to store the results on our Lead Record.  In this case we will use the field we just created DLRS_Completed_Tasks_In_The_Last_Week__c
  9. I want this to run in realtime
  10. I want this to bypass any sort of task privacy I might have set up in my org so I have it set to run as System

Once you have this record saved, you can deploy the child trigger via the manage child trigger button then go back and activate the rollup.  Now you will also want to click Calculate to backfill all the records, this might best be done at night as it will take a while to run through all your lead records.  Then you can build a Lead List view for the SDR’s where the DLRS_Completed_Tasks_In_The_Last_Week__c <= 2.  As this is a realtime Rollup that has a date field as a criteria you might want to set up a schedule Calculate to re-run all leads where that value is above 2 every Sunday night so come Monday it is a fresh value for the SDRs to work.

 

22 thoughts on “Counting Tasks with DLRS

  1. ErikN

    Can you count tasks by Type? Our Marketing dept, would like to see how many total lead touches occurred but also see a count by type.

    Reply
    1. Dan Post author

      You sure could, you would just add to the relationship criteria the type of task you would like to count. So say you have 3 types you’d have 3 DLRS’s one that counts each different type.

      Reply
  2. Mark Deuel

    You aren’t able to report on tasks after a certain amount of time. Would the ability to do a DLRS on tasks have the same limitation?

    Reply
    1. Dan Post author

      Yup with the checkbox All Rows it will grab archived tasks just be warned that checkbox will also pull up things in the trash bin.

      Reply
  3. Mark Deuel

    Sorry Dan, so DLRS will NOT be able to roll-up tasks past a certain time period? Currently our’s is set to 365 days.

    Reply
  4. Rajn Bhagta

    Can we user developer mode insteand of real time mode , actully when i am using real time it is showing some error with meta data api . so i dont want to click on deploy trigger,it tried with developer mode but but every time i need to click on calulate then only it is calculating new job is it possible to make it automatic.how schedule mode is working?

    Reply
    1. Dan Post author

      Developer Mode is another way to have it run in real time. If you want to run recalculates you’ll need to use the schedule calculate mode.

      Reply
  5. Rajn Bhagta

    @dan Thanks for your reply.

    i am not getting option to schedule calculate mode . can you please help me how i can schedule calculate mode.do we need to write batch apex class

    Reply
    1. Dan Post author

      You shouldn’t need to write batch apex at all. There is a button on the DLRS record named “Schedule Calculate”, if you press that button you can set up a custom time frame org wide recalculate. Also if you want to run real time but are running into the Metadata API issue you can just deploy the trigger in Sandbox and then move the trigger over via a changeset and it will still find all active DLRS records that are pointed at that child object.

      Reply
  6. Rajn Bhagta

    Unfortunately i can’t see schedule calculate button on my record.as task is very frequent activity for our org so we cant use real time because it will execute trigger every time when task will be added or deleted it will be really great if you can help me to schedule DLRS .FYI i am using 2.9 version of DLRS.

    Thanks

    Reply
      1. Rajn Bhagta

        Hi Dan ,

        i am using 2.9 version of DLRS , can you please confirm on which version schedule calculate button will be there.can you please help me to setup in developer mode.

        Thanks

        Reply
  7. Jordan

    I’m running into an issue with Shared Activities. I’ve created a DLRS to display the most recent activity on the contact record (the standard Last Activity date field doesn’t meet my needs). However, it appears that DLRS only counts tasks on which the contact is the primary contact. Is there any way to have secondary contacts included as well? Otherwise, I will have to ask my users to duplicate their tasks to get my workflows to trigger correctly.

    Thanks for the help!

    Reply
    1. Dan Post author

      For just moving a single field over on something as heavily used as Tasks I’d recommend using Process Builder. Also the way that Tasks are related to multiple contacts if I recall is a bit strange but I haven’t played around with it much.

      Reply
  8. Leigh-Anne Nugent

    Just discovering DLRS and seeing it’s potential. Thank you for writing such detailed (and current) notes on this!
    Have you come across a use case to identify the most recent Task by type? The end result is to be able to pull a report of all of the lastest Tasks for all Accounts, without having to pull all of the tasks and sorting by date and ignoring all of the older records. Considering this will have to constantly updated as new records come in, is this an APEX solution or could DLRS help here?

    Reply
    1. Dan Post author

      Do you just want the most recent task date on the account or the task id? What is your end goal of the report?

      Reply
  9. Rajn Bhagta

    Hi Dan ,

    i am using 2.9 version of DLRS , can you please confirm on which version schedule calculate button will be there

    Reply
  10. Rajn Bhagta

    hi dan,

    i am getting “Attempt to de-reference a null object
    An unexpected error has occurred. Your solution provider has been notified. (dlrs) ” error when i am trying to click on rollupscheduledcalculate vf page preview option. can you please help me with above error

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *