Saturday, March 8, 2014

Can"t change cost of filed less than previous value

// cant decrese the cost not less than previous value
trigger Trg1 on Empl__c (before update) {
  
    if(trigger.isupdate){
        for(Empl__c Emp1:trigger.new){
            for(Empl__c Emp2:trigger.old){
                if(Emp1.cost__c<Emp2.cost__c){
                    Emp1.adderror('cant');
                } 
            } 
        }  
    }  

}

No comments:

Post a Comment