Newer Version Available

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

Apex Trigger: Prevent Closure of Work Orders with Open Line Items

The following trigger prevents users from closing a work order unless all its line items have been closed. It’s a good way to ensure that all scheduled tasks are completed. The accompanying unit test scans your code for issues.
To define a work order trigger in your org:
  1. From Setup, enter Work Orders in the Quick Find box, then select Triggers under Work Orders.
  2. Click New.
  3. Copy the trigger text and paste it into the text field.
  4. Click Save.