1

I have two different business units that are wanting ways to verify that an object as well as certain related (not necessarily master-detail) objects have a specific number of attachments before allowing the main object to enter the approval process. In initial research, a team member found the project created by DouglasCAyers aka afawcett on GitHub named 'declarative-lookup-rollup-summaries', which can be found here: declarative-lookup-rollup-summaries. I am not sure that this fits our needs though. Attachments are apparently their own standard object and I am not sure that they fit the definition of a lookup field, although, I certainly could be very wrong about that.

Another solution that would definitely work, but involves a trigger was provided by bob_buzzard in August of 2011 here: Bob's answer. Basically, creating a trigger that selects a count from the attachment object based on the specific parentid. Tracking the decrement when an attachment is deleted would also be necessary.

Currently, both of these business units are using Salesforce in Classic, but we are planning to try and move our org to Lightning in 2018-2019. Since attachments in Lightning are not handled the same way as they are in Classic, I don't want to suggest a solution to our current problem that is going to make moving to Lightning any harder than if I had recommended/implemented a different solution. Also, I am open to any other thoughts and ideas beyond what I have already found.

  • Basically Bob's answer and declarative-lookup summaries are doing the same, only difference is in Bob's answer you need to write code where as in declarative rollup you don't need to write code, this tool will automatically generate code for you. I have used declarative rollup in my project for similar requirement – salesforce Developer Dec 1 '17 at 17:22
1

Any time you go from one record to another, it's a lookup. Both DLRS and other homebrew solutions fall under this category. I would advise that you use the standard rollup summary fields first, when possible.

Even though files have difference appearances in Lightning and Classic, they basically use the same underlying objects, so whatever you implement today will probably work in the future; and if not, using DLRS will reduce your efforts to basically a minor configuration change.

  • So, you can't create a rollup field on something that doesn't have a lookup relationship with the object. You also can't create a lookup relationship for an attachment, so this leads me to believe that my goal of counting attachments must be done with a trigger on the attachments object. – AstroLovesCodey Dec 1 '17 at 20:54
  • 1
    @AstroLovesCodey They have lookups, but not the sort that allow rollup summary relationships (much to my annoyance, honestly). Polymorphic relationships and those that are not master-detail are not supported for the built-in rollup summary field. That said, you do need a trigger (DLRS uses this method), because not even Process Builder supports attachments right now (if ever). – sfdcfox Dec 1 '17 at 21:03
  • See below for DouglasCAyers answer on my twitter post. – AstroLovesCodey Dec 1 '17 at 21:07
  • 1
    @AstroLovesCodey Yes, we're all basically saying the same thing. My point was, let's say you have master A, child B, and attachments on B. You can use DLRS to update B, and B can automatically roll up to A, if you need it. You should use standard rollup summary fields first, when possible, and use DLRS when not. – sfdcfox Dec 1 '17 at 21:25
0

Per DouglasCAyers aka afawcett and liked by @andyinthecloud, "Your idea is correct, use @andyinthecloud declarative lookup rollup tool. The parent object will be whatever your approving. Parent field either Attachment.ParentId or ContentDocumentLink.ContentDocumentId (if using Files)." His tweet reply can be found here.

  • Just for the record, Doug Ayers and Andrew Fawcett are both awesome, both MVPs, but distinct people. – gorav Dec 2 '17 at 13:42

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.