• ERHAN BALLI 9
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
Hi I am new in salesforce. I am trying to learn about triggers and update mu student fees in my custom project. My code is not giving any errors but also it is not update the Student_Payment__c. Can someone help me about this situation my code is like that.. 


trigger StudentFeeCalculation on Student_Record__c (before insert, after insert, after update, before update) {
    
    Decimal ScholarFee = 0;
    Fees__c newFees = new Fees__c();
    Student_Record__c Std = new Student_Record__c();
    
    //Calculating the sport scholarship of students
    
            if(Std.Scholarship__c == 'Sport Scholarship')
         {           
             // For computer engineering students
             if ( Std.Department__c == 'Computer Engineering')
             {       
                     List<Fees__c> SFee = new List<Fees__c>(); 
                    SFee =  [SELECT Fees__c.Department_Fees__c FROM Fees__c WHERE Fees__c.Name = 'Computer Engineering Fees'];
                     List<Student_Record__c> StdPayment = new List<Student_Record__c>();
                    StdPayment = [SELECT Student_Record__c.Student_Payment__c FROM Student_Record__c];
                
                 //Update fees for every student    
                 for(Student_Record__c stdPay: StdPayment)
                 {
                             ScholarFee = Integer.valueOf(SFee);
                             ScholarFee = ScholarFee * (25/100);                              
                             update StdPayment;
                 }         
               }   
             }     
           }
Hi I am new in salesforce. I am trying to learn about triggers and update mu student fees in my custom project. My code is not giving any errors but also it is not update the Student_Payment__c. Can someone help me about this situation my code is like that.. 


trigger StudentFeeCalculation on Student_Record__c (before insert, after insert, after update, before update) {
    
    Decimal ScholarFee = 0;
    Fees__c newFees = new Fees__c();
    Student_Record__c Std = new Student_Record__c();
    
    //Calculating the sport scholarship of students
    
            if(Std.Scholarship__c == 'Sport Scholarship')
         {           
             // For computer engineering students
             if ( Std.Department__c == 'Computer Engineering')
             {       
                     List<Fees__c> SFee = new List<Fees__c>(); 
                    SFee =  [SELECT Fees__c.Department_Fees__c FROM Fees__c WHERE Fees__c.Name = 'Computer Engineering Fees'];
                     List<Student_Record__c> StdPayment = new List<Student_Record__c>();
                    StdPayment = [SELECT Student_Record__c.Student_Payment__c FROM Student_Record__c];
                
                 //Update fees for every student    
                 for(Student_Record__c stdPay: StdPayment)
                 {
                             ScholarFee = Integer.valueOf(SFee);
                             ScholarFee = ScholarFee * (25/100);                              
                             update StdPayment;
                 }         
               }   
             }     
           }