Andy in the Cloud

From BBC Basic to and beyond…

385 thoughts on “New Tool : Declarative Rollups for Lookups!

  1. How do you add limit? like do the sum of the last 5 records?

  2. how to add order by and limit?

  3. This looks great. But we would like to use it a little differently….
    We are trying to setup a bunch of rollup rules on a given dataset that would populate an object that contains the results of all those rollups (with a label that matches the rollup name)
    In other words have a parent child relationship doesnt fit our needs, we want to just run the rollups against a dataset and as a result “build” a new dataset containing all the results.

    Is there a way we can get the current release to work for us in that way. I can send you some examples if that helps.

  4. Pingback: Count total child records on Parent object in Lookup relationship | DL-UAT

  5. Pingback: Wine App Part 2 - Fixing My Mistake -

  6. Pingback: Mixed Sharing Model | DL-UAT

  7. Hi,

    How can I remove/un-deploy this tool? Please suggest.


    • It depends on how you added/deployed it in the first place.

      If you took the recommended approach you should uninstall via the Installed Packages page under Setup. Be sure to undeploy the triggers for active rollups via the Manage Child Triggers button (if you haven’t used this before ignore this step).

      If you took the Deploy to Salesforce button from Readme then you did an unmanaged deployment and will have to delete classes etc manually or via eclipse or other tool. Note that the unmanaged option if only recommended for developers.

  8. I had installed the source code in my dev org. Now I am encountering few exceptions and unable to find the list of related components. Please advise.

  9. I am really interested in trying this tool, but wonder if someone can tell me: does this tool “modify” the record it is rolling up to?
    (Don’t want to cause issue with workflows that run every time a record is edited!)

  10. I am so excited about this tool. I have started testing in my sandbox. We have been using Rollup helper for a year but it just doesn’t work properly. I was just curious as to why this isn’t on the appexchange?

    • It is available as an AppExchange package as such, just not really got round to fully listing it that all. Glad you like it and happy rollups! 🙂

  11. Hi,
    One quick question. I have installed the package in Development sandbox. I created the trigger to do Rollup Summary. How I can move this setting from Development Sandbox box to QA Sandbox using Change set.

    • Easiest thing to do is install again and repeat setup to be honest, the tool setup includes record data (the Rollup itself) and metadata and Changesets will only move the later

      • Hi Andrew,
        To understand better I am asking this question. I have installed the same package in QA also. Are you saying me to create the same settings which I created in Dev sandbox ie App->DLRS -> Lookup Rollup Summaries -> New -> the required values(Child object name,Master object name, Relationship name, etc.,) which Change set will not move.

      • Yep you got it

  12. Hi Andrew,

    Is this tool subject to the limit on the number of roll up summaries per object? Or does it mimic the rollup summary function, and so bypass the limit?


    • It is not subject to those limits, but is subject to others around the amount of records your rolling up, review the Readme file for more details.

  13. Hi Andrew,

    Your app really helped me to solve my business requirements .But i have one issue ,This app classes are running in ‘With Sharing’ mode , how to make them as ‘Without sharing’ ,please help me to do this.

    • This would have to be a feature enhancement. Can you please log it on the GitHub Issues list, with details of your use case. Thank you. I will also point out some code changes if you want to try to make the changes yourself.

  14. Pingback: How to write a rollup summary trigger for a lookup relationship | DL-UAT

  15. Pingback: 6 Tools to Help you be Ridiculously Efficient in Salesforce

  16. This tool is fantastic. Thank you so much for creating it. Count Distinct is a life saver. Is there any way to SUM or AVG Distinct?

    • Your welcome! The platform query language does not appear to support this, which is the most optimal way the tool prefers to support things. Lately I have started added other operations that use code to calculate, this gives more flexibility but requires more processing and thus brings with it more chance of hitting governors. So sum and avg distinct is possible just may not be as efficient. Worth adding it the the GitHub issues list I would say, i will mark it as an enhancement for future consideration.

  17. Does this tool have the ability to roll up on a object that does not have a parent-child relationship to the parent record? I’m trying to get results on my parent object but using a field that is common with two objects. For example, Object A & B both have a relationship to the Contact object, however Objects A & B have no relationship between each other and I want to roll up information from B into A using the ContactID as the “Relationship Field”. If that doesn’t make sense I can elaborate further…

    Is this possible? or possible with a work around. Thanks.

    • Sorry Darrin, this is not possible, it has to be a direct relationship. Happy for you to lodge an enhancement idea on the GitHub Issues list though, sounds interesting. 🙂

  18. Hi Andrew, look like great tool! Getting an error: “Error: Invalid Data.
    Review all error messages below to correct your data.
    Apex trigger financialtransactionTrigger caused an unexpected exception, contact your administrator: financialtransactionTrigger: execution of AfterUpdate caused by: System.TypeException: Invalid id: 164010000.00: Class.RollupService.triggerHandler: line 299, column 1”

    • Can you raise this issue in the GitHub Issue’s list on the repo, and perhaps cross post to the Chatter Group (see Readme for link), i’ll hopefully take a look this weekend. Please include a screenshot of your rollup definition and some details on the fields your referencing.

  19. I created a summary to count the number of attachments as I want to do a validation rule where there has to be at least one attachement. I create this on a custom object where the name (request number) is the relationship field to the attachment. It worked as far as counting the existing one record that I had attached to the custom object; however, when I went to add another attachment (to see if it summed to 2), then I got the following error, when I tried to attach the file. Error: Apex trigger dlrs_AttachmentTrigger caused an unexpected exception, contact your administrator: dlrs_AttachmentTrigger: execution of AfterInsert caused by: System.StringException: Invalid id: account by zone by state.xls: (dlrs)

    • The tool has a problem with children that have different types of parents, there is an issue on GitHub with this problem, please add your use case here. I hope to fix this soon.

  20. I got it to work when I changed the Relationship Field to “ParentID”; however, when I logged in as another user, I was not able to attach a document. Access Denied. Would that be because I have the field to update as a Read-Only?

  21. How do I use this tool on rollups for the Task Object? Tasks have a different kind of relationship field including a pick list to select the related object type and a lookup to the actual record. on the field list for tasks the field seems to be named “What”, but when used for building the rollup summary with this tool the error message “Field does not exist.” is displayed.
    Is there a different field name I have to use?

  22. Hi Andy, no data ever leaves the platform while using this method, correct? We are looking at your tool but want to ensure data security. Thanks for your help!

  23. Hi Andy, this is too good app, would you please confirm me as this is free and open source and if any plans to put on appexchange along with a fee in future.

  24. Hi Andrew, is it possible to use OR conditions with this tool? I have been hitting the following error ‘First error: unexpected token: OR’ when the WHERE SOQL has been: ‘RecordTypeId = ‘X’ OR (RecordTypeId = ‘Y’ AND Status IN (‘A’, ‘B’, ‘Active’)). Thanks,

    • Yes it is possible, post you needs to the chatter group (see readme) and either other community members or myself can help

  25. I am trying to use this rollup on a existing rollup that SF has— I have a rollup on Accounts for specific Opps. I need this number from all related Accounts under Building to rollup into this other field on building. Goal: to be able to see all accounts under (Custom object) Building to rollup SUM of total rollup already set up on Accounts—any possible help the related field to my custom Building and Account is not working.

    • I am a little busy with Dreamforce prep, but if you post on the chatter group someone else in the community will likely help you.

  26. Hi Andrew, I think your tool is fantastic – my only issue is that I’m hitting the 50 000 limit! Any advice on what to do about it? Other than turn off the rollup!

    • You can switch to schedule mode and also review the apex jobs page to see if you need to adjust the batch chunk size. I covered this setting in one of my later blogs: see the full list of blogs on the readme file in the repo. Thanks!

  27. hi there – is there a minimum licence for this tool? I’ve used it before (AND LOVE IT) but trying to release into my current clients instance I am getting the error below.

    Dependent class is invalid and needs recompilation: dlrs.rollupsummariesselector: line 30, column 46: Invalid type: fflib_SObjectSelector managetrigger: Dependent class is invalid and needs recompilation: dlrs.rollupsummariesselector: line 30, column 46: Invalid type: fflib_SObjectSelector
    (LookupRollupSummariesReadOnly) In field: apexClass – no ApexClass named fflib_SObjectSelector found LookupRollupSummariesReadOnly: In field: apexClass – no ApexClass named fflib_SObjectSelector found

    • Looks like you deploying the code unmanaged, any reason why you don’t just install via the package?

      • Not intentional i clicked on the Production link for the latest release and went from there. Is the link going to the wrong place? Another guy is having the same issue and posted on Github.

      • For package release that is the correct place. Looks like this could be an SF issue as far as i can see at the moment…

  28. I am getting an error when trying to set up a new rollup summary. It’s saying the child object that I have selected does not exist. I currently have a lookup relationship between Accounts and a custom object, but the rollup summary tool is not recognizing my custom object.

    • It maybe that you need to get the API name of your object correct or try to use the pilot ui page and pick from the drop down: if neither of these work try submitting your issue with screenshot to the chatter group (see readme for link) and someone from the community or myself can try to help further.

  29. Is there any risk of hitting an API limit with Salesforce when implementing a lookup?

  30. Hi there – GREAT TOOL, thank you! Is it possible to do multiple relationship criteria? I want to roll-up a dollar value if two conditions are met. Just not sure how to do it. Thanks ahead of time for your time.

    • Thanks your welcome! Not quite sure what your meaning tbh, can you post more details on the Chatter group (see link on readme file in repo). Thanks!

  31. Hi Andrew,

    I’ve just installed this package into sandbox but I’m rather confused as to how to achieve what I want, I’d be grateful if you could tell me what I want is possible?

    Basically, I’ve Accounts with Contacts, enabled as Community Users.
    They creates cases, which through Apex creates a custom object called Switchover.

    I want to put on the Account, the date of the most recently created Switchover – (i.e. the last time a user in that Account created a record)
    The SUM of Switcovers this month – ie this months activity frmo that Account
    The SUM this year of Switchovers – similar to above

    There is a direct link from Switchover->CreatedbyId->AccountId

    Any help appreciated!


    • Yeah this should be possible with the link you have, have you gone through the documentation links on the readme? There is also a Chatter group for my detailed questions. Basically you need enter the parent object, Account, child object, Switchover object and the relationship field on your switchover object, then it sounds like your need the Last operator from the pick list? This blog comment is not ideally placed to go into more details tbh, the chatter group is well covered at the mo though. Hope this gets your started!

    • There is also a good blog I retweeted at the weekend, might want to take a look at that also, check my Twitter posts

  32. This is a great tool! However, I just setup a roll up of a field on a task to a custom object and it’s not happening real time. I had to hit calculate for it to update. Any insight to why that would happen?

    • Can you perhaps share on GitHub or the Chatter Group (see Readme) please include screenshots and steps you have done to setup and steps your taking to try it out. Me or the excellent community round this tool will I am sure be able to help you much better this way. Thanks!

  33. Where is the button to donate to your beer fund? I’m serious! Great tool! Heard about it at the Berlin Developer group meeting last night and am stunned. Was thinking something like this could be made, and here you did it two years ago. How did I miss it? I’ve got a bunch of triggers I can now ditch! Thanks so much!

  34. Love your tool….I am using a relationship criteria with an OR statement and it is complaining…
    Revenue_Date__c = LAST_N_MONTHS:12 OR Revenue_Date__c = THIS_MONTH

    If I change the OR to an AND…it works fine.

    I am trying to sum up an amount value for the 12 months – current month and back 11…

  35. Hi Andy,
    Thanks for this tool! I’m trying to do a rollup count but notice that a ‘Field to Aggregate’ is still required. I tried the ‘power of one’ formula field idea but that doesn’t seem to get recognised. How do I do a count of the child object if I don’t have a field with 1 in it – is there a way?

    • Just use the ID field

      • Thanks, I put in the CaseNumber which accepted but now I’m getting: Active: Apex Trigger dlrs_CaseTrigger has not been deployed. Click Manage Child Trigger and try again. Could it be that my hope of rolling up a count of cases by contact will not work due to the relationship?

      • Click the Manage Child Trigger button then click Deploy, then retry to Activate

      • There was no button

        James Simpson | Salesforce Manager | +44 7825 083 024

      • Ok. Can you post something in the chatter group, see readme in repo for link, with a screenshot of what you see please.

  36. Hi Andrew – I am trying to install this, and I believe I am following directions, but the tab doesn’t show up. I add the remote site setting (, changing the eu2 to cs4 (my sandbox instance). After saving the remote site as active, is the Lookup Rollup Summaries tab supposed to show up? No idea how that is supposed to work. Any idea what I am doing wrong?

    • Have you assigned the permission sets?

      • Hi Andrew – I have not. I am not sure where to look. I am an administrator. Should I not be able to see the tab automatically?

      • It depends how you installed it, there are some options that assign objects and tabs to the installing user. If not, go under Setup, take a look for Permission Sets and look for the DLRS ones.

  37. If you create a bunch of rollups based on the relationship being a lookup then you change the relationship to a master-detail, will that have an effect on the rollups you’ve created?

  38. I’m not sure this posted so I’m going to leave my question again. If i have created a bunch of rollups for a lookup relationship using DLRS and I switch the relationship to a master – detail relationship, will that have any effect on the rollups I’ve creating using DLRS? Thanks!

    • Just answered the question in your other comment. I don’t mind answering questions here. However if you look at the readme for the tool you will find a Chatter Communty group, where I and others hang out and can also take questions that way.

  39. Thanks so much for creating this app! – Question: I’m trying to set Relationship Criteria to look for two distinct values in a Picklist but can’t seem to get the SOQL syntax correct… or is this even possible? Can I use OR in this fashion?

    • Your most welcome! Take a look through the Chatter group there is a few pick list examples in that. Let me know if you cannot find them I will have a look.

  40. @Andrew Fawcett I have a requirement inwhich I have to count no of active contacts(related list) per account….On my account in the related child list there is a picklist field called as ‘Status’.How can count it? As there is lookup relationship between account and contract.I am trying to count with the help of tools that you have provided but failed to calculated it…

    • Set Account as your parent object and then Contact (or Contract) as your child. Then in either case the AccountId field is what you put in the Relationship Field field. In the Relationship Criteria field enter something like…. Status ‘Complete’ Finally be sure to put Status in the Relationship Criteria Fields field. So that changes in status trigger a recalculation. I would also recommend you checkout the Chatter Group (link from the main README file) for further ideas and assistance. Others and myself also hang out there. Hope this helps!

  41. Can you create a SOQL query that looks at a date field for all the lookup records and can select the most recent date? I haven’t figure out a way to get this to work.

    Also, is there a definition for Concatenate vs Concatenate Distinct?

    • Actually looking for definitions for the fields in Roll up details section; Field to order by, Aggregate Operation, Aggregate result field, we’d like to pull in the value from a lookup field but we are getting the SF ID instead of the name. Thanks.

    • You might have better luck on the chatter group for specific examples, but yes, you can sort date fields using ASC/DESC. Concatenate distinct removes duplicates from a list of returned values.

      • Yes, sorry, I do try to respond quickly, but these days the awesome community chatter group is way faster than me! 🙂

    • Yes you can use the First Rollup operation for this. Also see the readme file for the documentation section, that links to blogs explaining key features.

  42. Hi Andrew, I am using your app and it is wonderful. I use it to get child account count and survey score and show on parent account.

    I am only getting error when i trying to Merge account. Please find below error msg:

    Apex trigger dlrs_AccountTrigger caused an unexpected exception, contact your administrator: dlrs_AccountTrigger: execution of AfterDelete caused by: System.NullPointerException: Attempt to de-reference a null object: Class.dlrs.RollupService.updateMasterRollupsTrigger: line 938, column 1

    I would appreciate if you could help me to figure out the issue.

    • This looks like a bug. Are you using Custom Metadada?

      • No, I don’t think so.

      • If you are using the Manage Rollups tabs you are using custom Metadada

      • Hi Andrew, I’ve got exactly the same problem. My DLRS is configured on Metadata. What may be a reason for it? We are using dlrs for quite some time, also with the merging option, and this only came up after we added two additional rollups to Account recently.

      • I will take a look this weekend to try and fix this, others are finding it also. Standby. 🙂

  43. Pingback: Salesforce MVP – Are you a good candidate ? – Advanced Force Developer

  44. is it possible to filter for opportunity created date = product created date?

  45. Thank you, thank you, thank you for developing this tool! Am an admin and don’t have a clue about “tech stuff”. May I ask you a few questions: Just created my first roll up and found it pretty self explanatory (due to the good help texts). I asked to run a calculation but nothing happens. Not sure if I made something wrong (didn’t get any errors) or if I am just too impatient.

    Trigger that is deployed: What name does it get? Is it best practice to include e.g. “RU” (for Roll Up) in the API name field of the Lookup Rollup Summary Name?
    It adds a trigger for each rollup. Best practice in Salesforce is to have one trigger per object. However: if all the rollup triggers get put into one, it isn’t really a “declarative” tool anymore as everytime one is added or de-activated the single object trigger would have to be changed. What do you think?

    Are there any other best practice things I should be aware of?

    • Trigger name is generated based on the child object name, you cannot change it by default. If you want to merge triggers into one, then you can set your Rollup as Developer and not Realtime. Then call the Rollup API from your existing trigger.

    • And your very welcome btw! Thank you! 👍🏼

  46. Hello Andy. I think I have bumped up against a use case that is resistant to the DLRS solution and wanted your feedback.

    I need a count field populated on the Contact record. I want to count up child records that meet a certain criteria, but if no child records meet said criteria I want the count to be zero. I need to recalculate this count each time certain child records are added/updated/deleted.

    In other words, lets say the rollup summary got calculated as 1 because there was one child row that met the criteria to be included in the count.

    Now the child row changed so that NO child rows now meet the criteria. So, I need to rollup field to be recalculated to zero.

    I cannot figure out how to do this. The only think I can do is add Relationship Criteria to the Lookup Rollup Summary definition. But if I do the field will not recalculate when the criteria is no longer met.

    The problem I have is … I think I could do this with a formula, but I need the last modified date on the parent record to be updated whenever any changes are made to the child records to constantly determine whether a certain condition is met or not. The current value of this count must message over to SilverPop (it will be used to determine mailing eligibility for a particular email campaign), so I need to force the parent record to update whenever this condition changes.

    • Why is it not going to zero?

      • Hi Andy. Here is the scenario:

        A. I need a count of child records rolled up to the parent, but only for those child records where condition y = true. If I have 5 child records and only one of them meets condition y, then the rollup count should be 1.

        B. This has to be recalculated each time there is any change to any of the child records. So now if there are zero child records out of the 5 that meet condition y, the rollup count should be zero.

        My dilemma is: If I use relationship criteria in the DLRS definition to make sure I enforce rule A, then the rollup will not recalculate as per rule B because at that point there is no longer a relationship. I did confirm this to be the case by manually manipulating the data on the child records.

        Does that explain better? Is there something I am doing wrong? Thanks.

      • Once the last child is deleted or updated that does not meet the criteria it should set the rollup to 0? As per this code,

      • Hello Andy. Thanks so much.

        After your feedback and guidance, I started going over the criteria very carefully. I realized the second criteria condition was referencing the wrong field. So the rollup was always going to calculate as long as the first condition was met.

        When I only used the first condition, the system worked just as you described it should.

        Sorry for the trouble.

      • No worries, glad your sorted!

  47. Hi Andrew, I have been using your DLS in my production org for a while now. It is absolutely wonderful, great job. But I was wondering if it is possible to install it in my dev org? All the links that available to do so, give me an error saying authentication failed.

    • This is an issue with GitHub Deploy, assuming you want the unmanaged code so you can edit it etc, just make sure you are logged out all your orgs, ideally close and fully quit your browser, then try the Deploy to Salesforce button again.

  48. Hello, I have a daily mass data upload of my related records that is causing the DLRS triggers to run after EACH record is updated. There are thousands. I was trying to implement the Scheduled method, but am not sure how to stop the immediate trigger functionality from happening too. Any pointers will be appreciated

    • There are two schedule modes. One still needs the trigger but only in a light way, the other does not need a trigger at all. If you set the Calculation Mode to Scheduled , then trigger just logs parent records to be later updated by the RollupJob scheduled Apex class. Alternatively if you are happy for a scheduled full recalculate to happen, set the Calculate Mode to Process Builder (this is a hack for now) and then use the Schedule Calculate button on the Rollup. In this second option you don’t need the trigger and if deployed click Manage Child Trigger to remove it.

  49. Hi Andrew,

    This is really amazing! And your patience in responding to every single question is awesome!

    Really appreciate your vast experience, humbleness and eagerness to help the Salesforce developer community!

    Best regards,

  50. Hello Andrew,

    We are trying to use your tool to update our Campaign Values for Total Won Opporutnities and Total Won Opportunities Amount. For some reason, I could to get the following error: Error:Apex trigger dlrs_OpportunityTrigger caused an unexpected exception, contact your administrator: dlrs_OpportunityTrigger: execution of AfterUpdate caused by: System.TypeException: Invalid id: true: (dlrs).

    I have the following configured for this. If you have an email, I can send you a screenshot. However, I am using IsWon Field as my aggregate field, and it doesn’t seem to be calculating in Campaign Records. Can you help or let me know how I can get this done with your tool. Thanks.

    • Hi, it’s best to either post an issue on the github project page or better still post on the community chatter group (linked from the readme file). You can attach a picture of your roll up in either of these places.

      • Thanks, Andy! I have posted to the chatter group. I got almost everything working except RealTime. Thanks!

Leave a Reply

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

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

Facebook photo

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

Connecting to %s