You need to sign in to do that
Don't have an account?
m pandey
salaries of contacts should be calculated and total of salary should be updated in account field of salary in trigger.?
account - fld-Total sal-intger r currncy
contact -fld -sal of cntct-intger r currncy
when ever we create cntct and sal is added in the field all cntct sal of total should be updated in account total sal field
Task-ex: if we have 5 cntcts of sal(10.000,25.0000,55.444,22.000,77.0000) while creating f recrd and updatng the recrd in sal fld in cntcts
it should be total in accnt fild total salary.....?
contact -fld -sal of cntct-intger r currncy
when ever we create cntct and sal is added in the field all cntct sal of total should be updated in account total sal field
Task-ex: if we have 5 cntcts of sal(10.000,25.0000,55.444,22.000,77.0000) while creating f recrd and updatng the recrd in sal fld in cntcts
it should be total in accnt fild total salary.....?
try this code....
Trigger::
trigger SumUpSalaryInAccount on Contact (after update,after insert) {
list<id> accids=new list<id>();
list<account> accnames=new list<account>();
for(Contact c:trigger.new){
accids.add(c.AccountID);
}
List<Account> accs=new List<Account>([select id, shobithapp__contact_name__c,shobithapp__total_salary_del__c,(select id,Name,shobithapp__Salary__c from contacts) from Account where id in:accids]);
decimal n=0.00;
for(Account a:accs){
for(Contact c1:a.Contacts){
n=n+c1.shobithapp__Salary__c ;
}
a.shobithapp__total_salary_del__c=n;
accnames.add(a);
}
update accnames;
}
Please let us know if this will help you
thanks
vishnu R
All Answers
try this code....
Trigger::
trigger SumUpSalaryInAccount on Contact (after update,after insert) {
list<id> accids=new list<id>();
list<account> accnames=new list<account>();
for(Contact c:trigger.new){
accids.add(c.AccountID);
}
List<Account> accs=new List<Account>([select id, shobithapp__contact_name__c,shobithapp__total_salary_del__c,(select id,Name,shobithapp__Salary__c from contacts) from Account where id in:accids]);
decimal n=0.00;
for(Account a:accs){
for(Contact c1:a.Contacts){
n=n+c1.shobithapp__Salary__c ;
}
a.shobithapp__total_salary_del__c=n;
accnames.add(a);
}
update accnames;
}
Please let us know if this will help you
thanks
vishnu R
thank u so much buddy..............u Always rocks.............
may i know u r mail id........?
or
timings available in communities..............