I'm trying to create a before insert trigger that will prevent creating an order task if the order item has a checkbox not marked. If it is checked then let the task get created. It throws the error when the checkbox is checked or not checked.
Not sure what I'm missing.
trigger PreventOrderTaskCreationonOrderItem on Order_Task__c(before insert) {
for (order_Task__c o: trigger.new) {
System.debug(o.Order_Phase__r.Order__Item__r.Order_Project__c);
If(o.Order_Phase__r.Order__Item__r.Order_Project__c == FALSE) {
o.addError('You cannot add an order project category to this item.');
}
Else {}
}
}