Im trying to create a Trigger on my Products. Would like to update the New checkbox field to false if the col is more than the newly inserted col and if the checkbox field is true. However the trigger codes below does not work.
trigger NewIn on Product__c (after insert, before update) {
Product__c prod = new Product__c();
List<Product__c> productsToUpdate = new List<Product__c>{};
for(Product__c p : Trigger.new){
Decimal col = p.Collection__c;
Boolean newi = p.New__c;
if(p.Collection__c > col){
if (newi == true){
newi = false;
productsToUpdate.add(p);
}
}
}//end for
update productsToUpdate;
}