Create the object called “Books” and create field “Price”(data type is Currency) under this object.
Whenever we enter some amount of money in the Price field and once we click on save
button, the value we entered in the Price field is 10% less than the actual price. This is
applicable for while both inserting and updating records.
trigger DiscountTrigger on Book__c(before insert, before update) {
List < Book__c > books = Trigger.new;
PriceDiscount.applyDiscount(books);
}
public class PriceDiscount {
public static void applyDiscount(List < Book__c > books) {
for (Book__c b: books) {
//b.Price__c = b.Price__c * 0.9;
b.Price__c *= 0.9;
}
}
}