You do not need any custom code to do this. You can just use configuration.
(1) Create an "Activity Association" for object "Request/Incident/Problem" called "Change Active" with code say "cr_chg_act" and Object Attribute "change.active".
(2) Now create a new macro (site defined condition) with the following information:
(a) Symbol: Change is Inactive, Object: Request/Incident/Problem, Macro Type: Site Defined Condition [SAVE]
(b) Now, add atomic condition - Sequence: 10, Attribute: Change Active, Data Value: Equals NO
(3) Now for "Incident Transitions", choose the transitions for which you want to restrict. As an example, I am choosing say from "In progress" to "Closed". Edit each such transition and add a condition "Change is Inactive". Also add the "Condition Error Message" as say "WARNING: Closure not allowed: The attached Change Order is still active."
You are done.
Now test for any Incident which has a Change Order that is active and try to change the status (in our case from 'In progress' to 'Closed'). It will not allow the transition and will throw the error message you configured above.
This may be extended for Problem and Request too in a similar manner.
All the best.
Indrajit Banerjee.