I have created a trigger on Opportunity and managed to test it and it ran smoothly and even tried it out on the sandbox and everything ran fine. I then decided to use addError() along with the trigger.
if(Trigger.isBefore){ // Error checking, will verify that a contract child does not exist, will also verify that if any variables are null.
for(Opportunity verifyOpp: oppsFromDB){
if(verifyOpp.service_Contracts__r.size() != 0)
{
String x = 'Hi';
trigger.newMap.get(verifyOpp.Id).addError(x);
}
}
.....
The exception error I get is : System.DmlException: Update failed. First exception on row 0 with id 006.....; first error: FIELD_CUSTOM_VALIDATION_EXCEPTION, HI:[]
Just an FYI the List I am doing a for loop works perfectly fine on the Trigger.isAfter bit, so I am pretty certain it isn't in the eternal loop.
Any help would be greatly appreciated.