You need to sign in to do that
Don't have an account?
trigger problem 7
before we insert a new record in the customer object calculate the tax field value based on salary field value and then insert??
How i reach the right code ..??
How i reach the right code ..??
Try this code
You can modify your calculations based on requirement
trigger calculateTax on customObj__c (before insert) {
for(customObj__c v:Trigger.new){
if(v.salary__c <= 0)
v.payTax__c = 0;
if(v.salary__c > 0 && v.salary__c <= 100000)
v.payTax__c = v.salary__c/10;
if( v.salary__c > 100000)
v.payTax__c = v.salary__c/20;
}
}
All Answers
Try this code
You can modify your calculations based on requirement
trigger calculateTax on customObj__c (before insert) {
for(customObj__c v:Trigger.new){
if(v.salary__c <= 0)
v.payTax__c = 0;
if(v.salary__c > 0 && v.salary__c <= 100000)
v.payTax__c = v.salary__c/10;
if( v.salary__c > 100000)
v.payTax__c = v.salary__c/20;
}
}