I am trying to create a rollup field using the DLRS tool. However, I am running into multiple problems.

Ideally, I would like to have my field find the most recent activity date and return the subject of that activity. I am unsure how to get it to return the subject and my initial attempts at building the SOQL have returned nothing but errors (saying its not a valid soql statement). And I'm not sure why! Any advice would be much appreciated. Below is the SOQL statement I built to find the activity with the most recent activity:

SELECT ActivityDate
WHERE ActivityDate < TODAY
ORDER BY ActivityDate DESC 

enter image description here

  • Have you seen the Last Activity Date field? Does that not do what you're looking for? – sfdcfox Sep 6 '18 at 15:51
  • 1
    Creating DLRS rollups generally doesn't involve writing a whole SOQL query. Can you include a screenshot of your rollup configuration? – David Reed Sep 6 '18 at 15:57
  • Hi David, I have attached a screen shot - thank you for your help! – AI_Ops Sep 6 '18 at 16:55
  • Is it possible that you need to add the fields being used from the query into the Relationship Criteria Fields? Also here is some example query codes, it looks like you might just need the bit after the WHERE, not the whole query...github.com/afawcett/declarative-lookup-rollup-summaries/wiki/… – Stas Christiansen Sep 6 '18 at 18:41
  • Hi Stas - Thanks! Yeah - I have also tried that and it did not make a difference. I am still getting the same error – AI_Ops Sep 6 '18 at 18:44

Your Relationship criteria for DLRS should just be the elements you want added to the WHERE clause. DLRS will use this to build a larger, more complex Dynamic SOQL query.

You'd populate that box with ActivityDate < TODAY, rather than including your whole query. Note that your ORDER BY clause is already represented in your Rollup Details section, as "Field to Order By", and your LIMIT by the choice of the "First" rollup operator.

You'll also need to change "Field to Aggregate" to "Subject", since you're not trying to grab and populate the Activity Date itself - you're just using it to order the results.

Lastly, WhoId is not the correct relationship field between Account and Task. You want either WhatId, for Tasks related directly to the Account, or AccountId, if you wish to include Tasks related indirectly through an Opportunity, Contact, or other object.

| improve this answer | |
  • David, Thank you so much for your answer! It gave me a much better understanding of how DLRS work. I did as you mentioned above, however am still getting an error. This time the error says, "Master and detail fields must be the same field type (text/id based) for First or Last operations.' – AI_Ops Sep 6 '18 at 20:38
  • @AI_Ops What is the field type of DLRS_Most_Recent... (text cut off) on Account? – David Reed Sep 6 '18 at 20:39
  • It is a Text field – AI_Ops Sep 6 '18 at 20:49
  • Hmm. Sometimes I have seen DLRS act like it's continuing to report an error whose cause has changed. If you build the roll-up anew, do you get a different error? – David Reed Sep 7 '18 at 4:03
  • Hi David, I tried creating a new one and it is giving me the same error. I will keep digging for answers. Let me know if you have anymore thoughts. Again, thank you for your help! – AI_Ops Sep 7 '18 at 14:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.