I want to sum the number of Opportunities Related Links using a field trigger (I know I can do a roll up summary, but i cant use it as it is unclickable for the object I am using); I was wondering how I could trigger an Apex Trigger based off changes to the related links of an object?

  • welcome to SFSE; your question is a bit unclear. Please see How to Ask to clarify using edit
    – cropredy
    Jun 3, 2019 at 20:05

1 Answer 1


You cannot. Triggers fire only upon changes to the object type to which they are assigned; that is

trigger MyTrigger on Account (before update) {

will only ever run on changes to the Account record. While those changes may be fired indirectly through sequences of events that start with a child record update, via automation, other Apex code, or roll-up summary fields, the trigger will only ever execute if an Account is affected by DML.

You cannot use a Roll-Up Summary Field in a situation where records are related by a Lookup Relationship, or if the criteria involve a formula field or anything else that falls outside the narrow scope of allowed criteria for a Roll-Up Summary Field.

Your other options are basically roll your own RUSF using Apex triggers, which will involve a child object trigger and possibly also a parent trigger (for parents that support merges), or use a tool like the free, open source Declarative Lookup Rollup Summaries package, which I recommend all the time. DLRS allows you to build roll ups across lookup relationships and use complex criteria.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .