You need to sign in to do that
Don't have an account?
Christopher Shade
Trigger with Criteria
I'm going through the intro to Apex Trigger's and SalesForce has you build the trigger below.
How would I add critera to the Trigger below so that the variable Books doesn't contain all records in the object Book__c?
For instance, it is apply a discount to the Price__c field. If I only wanted apply the discount if the price were beneath a given amount how would I code that?
trigger HelloWorldTrigger on Book__c (before insert) {
Book__c[] books = Trigger.new;
MyHelloWorld.applyDiscount(books);
}
Thanks.
How would I add critera to the Trigger below so that the variable Books doesn't contain all records in the object Book__c?
For instance, it is apply a discount to the Price__c field. If I only wanted apply the discount if the price were beneath a given amount how would I code that?
trigger HelloWorldTrigger on Book__c (before insert) {
Book__c[] books = Trigger.new;
MyHelloWorld.applyDiscount(books);
}
Thanks.
To exclude some of the records from the Trigger.new list, you'd simply create a new list, iterate the trigger records and only add those beneath the threshold, e.g.