I am unable to close a case because of the following error:

We can't save this record because the “Case After Handler” process failed. Give your Salesforce admin these details. This error occurred when the flow tried to update records: FIELD_CUSTOM_VALIDATION_EXCEPTION: Term field needs to be populated to Close Opportunity as Won. You can look up ExceptionCode values in the SOAP API Developer Guide. Error ID: 1044782339-66183 (1517150277)ok up ExceptionCode values in the SOAP API Developer Guide. Error ID: 1044782339-66183 (1517150277)

I have a validation rule set on the opportunity object:

AND( ISPICKVAL(StageName, "Closed Won"), ISNULL(Term__c) )

This is so that the contract term field is captured whenever an opportunity is being closed as won. How is this effecting the closure of my case when the validation rule is set on the opportunity object and what should i do to ammend my validation rule so it doesnt effect the case object?


1 Answer 1


SObjects don't really live in isolation.

Any time you have a trigger, operate on a record for an SObject that is the "Detail" side of a Master-Detail relationship, or use declarative tools that can insert/update other SObjects, you open yourself up to execute triggers for SObjects beyond the one that initiated the transaction.

So, through some chain of events, you do have a connection between Case and Opportunity. Your Opportunity is undergoing a DML update (explicit or implicit), and that means that the validation rules for Opportunity are going to be evaluated.

There are potentially many ways to "fix" this, to stop this validation rule from complaining, but the exact approach you use is going to be highly dependent on the customizations you've made to your org. The simple, general fixes here are:

  • Change your validation rule so that it can only complain about an empty Term__c when the StageName is changing to 'ClosedWon' (the current VR is only checking if the StageName is currently 'ClosedWon', you'll need to add an ISCHANGED() or PRIORVALUE())
  • Fix the issue in your existing records. Use DataLoader or some similar tool to find the records that run afoul of this VR, and then update the records so they have Term__c populated
  • thanks very much for this detailed answer
    – user120752
    Commented Aug 23, 2022 at 11:40
  • @user120752 If your problem has been resolved, then you should "accept" the answer you think was most helpful/correct. You don't need to do that, but it gives both you and the answerer "reputation points" (which lead to things like being able to comment on other people's questions and answers) and signals to the community that you don't need any more help with that question. It also helps other people with similar issues quickly find things that are likely to work for them.
    – Derek F
    Commented Aug 23, 2022 at 12:16

You must log in to answer this question.

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