You need to sign in to do that
Don't have an account?
venturec
Stop trigger execution if certain parameters are not met.
Is there a way to stop a trigger from updating or inserting a record if certain parameters are not met?
I have an if statement inside a For loop, and am testing values. If the conditions are not met, I don't want the record updated or inserted.
Here's my code if you need it:
public class clsAbstractRatingTeam {
public static void updtEventID(Abstract_Rating_Team__c[] abstRT) {
List<Events__c> eventID = new List<Events__c>([select Id from Events__c where Current_Event__c = true]);
Integer lstSize = eventID.size();
if(lstSize == 1) {
String eID = eventID[0].Id;
for(Abstract_Rating_Team__c ar : abstRT) {
ar.Event_ID__c = eID;
}
} else {
// ? stop execution and do not continue.
}
}
}
Thanks for your help.
Also, if you meant that the record should not get inserted or updated at all, not just with your apex code, you could use the adderror function.
you look for conditions to be a certain value, if they are not, you can use the adderror method to prevent the record from being inserted or updated. Instead an error will appear in the UI, either at the top of the record or on the field in question, depending on how you use the code.
Message Edited by JimRae on 01-12-2009 04:22 PM
else{
break;
}