You need to sign in to do that
Don't have an account?
chiranjib rout
please help with this trigger
hi guys,
I am trying to work on this trigger but unable to find the error. there are 2 objects invoice & revenue.if revenue object fields(salary=regular,salary processed=today & invoice type=time & material) and invoice object fields(categlory=individual, billing calendar=today & type= time& material) & both the objects ecode & emp codeare equal then RevenueWithoutST(REVENUE OBJECT) = subtotal(invoice object).
trigger subtotal on Revenue__c (after insert,before update ) {
List<Revenue__c> Revenue__c = New List<Revenue__c>();
Set<Id>ECode = New Set<Id>();
For(Revenue__c Rev : Trigger.New)
Revenue__c.ECode__c == Invoice__c.Emp_Code__c
}
List<Revenue__c> RevList = [Select Id,Salary_Processed_month__c,Invoice_Type__c from Revenue__c where id =: ECode];
{Revenue__c r = new Revenue__c();
Invoice__c inv =new Invoice__c();
For(r.Salary_Type__c=='Regular'&&inv.Invoice_Category__c== 'Individual')
If(inv.Billing_Calendar__c== system.today()&& inv.Type_of_Invoices__c=='Time & Material' && r.Salary_Processed_month__c==system.today()
&& r.Invoice_Type__c=='Time & Material')
{
r.Revenue_without_ST__c =inv.Sub_Total__c;
}
else
{
r.Revenue_without_ST__c =11;
}
Update RevList;
}
I am trying to work on this trigger but unable to find the error. there are 2 objects invoice & revenue.if revenue object fields(salary=regular,salary processed=today & invoice type=time & material) and invoice object fields(categlory=individual, billing calendar=today & type= time& material) & both the objects ecode & emp codeare equal then RevenueWithoutST(REVENUE OBJECT) = subtotal(invoice object).
trigger subtotal on Revenue__c (after insert,before update ) {
List<Revenue__c> Revenue__c = New List<Revenue__c>();
Set<Id>ECode = New Set<Id>();
For(Revenue__c Rev : Trigger.New)
Revenue__c.ECode__c == Invoice__c.Emp_Code__c
}
List<Revenue__c> RevList = [Select Id,Salary_Processed_month__c,Invoice_Type__c from Revenue__c where id =: ECode];
{Revenue__c r = new Revenue__c();
Invoice__c inv =new Invoice__c();
For(r.Salary_Type__c=='Regular'&&inv.Invoice_Category__c== 'Individual')
If(inv.Billing_Calendar__c== system.today()&& inv.Type_of_Invoices__c=='Time & Material' && r.Salary_Processed_month__c==system.today()
&& r.Invoice_Type__c=='Time & Material')
{
r.Revenue_without_ST__c =inv.Sub_Total__c;
}
else
{
r.Revenue_without_ST__c =11;
}
Update RevList;
}
I'm sorry but probably there was some issue with pasting your code. Currently it's not compiling at all. Can you paste it once again with code tags?
Anyway please tell what probles do you have with this trigger.
The FOR statement on line #5 needs to have a { right after the ).
If you do that - it might compile and execute - as long as you're only updating one record at a time. But then you've got more issues. The SOQL that you're doing on line#8 will fail when the trigger is stress tested. Remember, triggers can be called with up-to 200 records. So, in this case - you're doing a SOQL inside of a loop, and the limit of 100 SOQL's would be reached.