Newer Version Available

This content describes an older version of this product. View Latest

Apex Trigger: Auto-Close Cases with Closed Work Orders

The following trigger automatically closes cases when a work order linked to the case is marked Closed. It saves support agents from having to manually close a case after the related work is complete.

If a case has multiple work orders, the trigger fires the first time any related work order is marked Closed.

Note

You can set up Apex unit tests in the developer console to scan your code for any issues. To keep things running smoothly, Salesforce requires at least three-quarters of your Apex code lines to be covered by tests. The following unit test applies to this trigger.