Newer Version Available
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:
- From Setup, enter Work Orders in the Quick Find box, then select Triggers under Work Orders.
- Click New.
- Copy the trigger text and paste it into the text field.
- Click Save.