• shiva malli
  • NEWBIE
  • 0 Points
  • Member since 2016

  • Chatter
    Feed
  • 0
    Best Answers
  • 1
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
Hi friends,

I am writing sum trigger between two custom objects and program is saved but not executed properly like argument can't be null here i am passing values but it throws an error
 Trigger sum_of_amount on Employee__c(after insert,after update,after delete,after undelete)
 {
 List<Department__c> dept_amount=new List<Department__c>();
 set<id> Dept_id=new set<id>();
 for(Employee__c emp:trigger.new)
 {
 Dept_id.add(emp.deptid__c);
 }
 Decimal adding_amount;
 for(Department__c dept:[select id,deptname__c,(select id,EmpName__c,EmpSal__c from Employees__r) 
 from Department__c where id in:dept_id])
 {
 adding_amount=0;
 for(Employee__c emplist:dept.Employees__r)
 {
 system.debug('My Emp Salary value is +++++===='+emplist);
 adding_amount+=emplist.EmpSal__c;
 system.debug('Newly adding value is========++++++'+adding_amount);
 }
 dept.Total_amount__c=adding_amount;
 dept_amount.add(dept);
 }
 update dept_amount;
 }
Hi friends,

I am writing sum trigger between two custom objects and program is saved but not executed properly like argument can't be null here i am passing values but it throws an error
 Trigger sum_of_amount on Employee__c(after insert,after update,after delete,after undelete)
 {
 List<Department__c> dept_amount=new List<Department__c>();
 set<id> Dept_id=new set<id>();
 for(Employee__c emp:trigger.new)
 {
 Dept_id.add(emp.deptid__c);
 }
 Decimal adding_amount;
 for(Department__c dept:[select id,deptname__c,(select id,EmpName__c,EmpSal__c from Employees__r) 
 from Department__c where id in:dept_id])
 {
 adding_amount=0;
 for(Employee__c emplist:dept.Employees__r)
 {
 system.debug('My Emp Salary value is +++++===='+emplist);
 adding_amount+=emplist.EmpSal__c;
 system.debug('Newly adding value is========++++++'+adding_amount);
 }
 dept.Total_amount__c=adding_amount;
 dept_amount.add(dept);
 }
 update dept_amount;
 }