You need to sign in to do that
Don't have an account?

Trigger update problem !
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;
}
}
}
}
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;
}
}
}
}
Hope this helps.
The trigger should not required to fire on after events, hope below code will help you !!.
Thanks,
Siva.
I tried your code but my payment object is still empty on the page. Is it possible about the relationship problem between my two objects ? I create fees object and make it look up relation with Student Record object which is incliding the Student_Payment__c object.
Can you please provide us the objects name and relationship among them ? if possible provide us the objects fields.
Thanks
Sivasankar