You need to sign in to do that
Don't have an account?
chiranjib rout
Error :Line: 1, Column: 0 required (...)+ loop did not match anything at input 'trigger' getting this erron when i run the following trigger immediate suggest
trigger ctcupdate on appointment__c (after insert,after update) {
appointment__c app;
Appraisal__c aps;
if (aps.amount_of_Increment__c !=0 ||aps.amount_of_Increment__c !=null){
app.Current_CTC__c=app.Current_CTC__c + aps.amount_of_Increment__c ;
update app;
}
if (aps.Increment_Percentage__c !=0 ||aps.Increment_Percentage__c !=null){
app.Current_CTC__c= app.Current_CTC__c + (app.Current_CTC__c * aps.Increment_Percentage__c);
update app ;
}
}
appointment__c app;
Appraisal__c aps;
if (aps.amount_of_Increment__c !=0 ||aps.amount_of_Increment__c !=null){
app.Current_CTC__c=app.Current_CTC__c + aps.amount_of_Increment__c ;
update app;
}
if (aps.Increment_Percentage__c !=0 ||aps.Increment_Percentage__c !=null){
app.Current_CTC__c= app.Current_CTC__c + (app.Current_CTC__c * aps.Increment_Percentage__c);
update app ;
}
}
Also You cannot update the same appointment__c record from Trigger itself, as salesforce will not allow you to do this, you will have to use @future methods to do the update.
trigger CTC_Update on Appraisal__c (after insert,before update ) {
List<appointment__c> AppList = New List<appointment__c>();
Set<Id> AppointIds = New Set<Id>();
For(Appraisal__c A : Trigger.New)
{
AppointIds.Add(A.ApplicantName__c);
}
List<appointment__c> AppointList = [Select Id,Current_CTC__c from appointment__c where id =: AppointIds];
For(Appraisal__c Aps : Trigger.New)
{
appointment__c A = new appointment__c();
For(appointment__c App : AppointList)
{
IF(Aps.ApplicantName__c == App.ID)
{
A.Id = App.Id;
IF(Aps.amount_of_Increment__c != 0 && Aps.amount_of_Increment__c != NULL)
{
A.Current_CTC__c = App.Current_CTC__c + Aps.amount_of_Increment__c ;
}
IF(Aps.Increment_Percentage__c != 0 && Aps.Increment_Percentage__c != NULL)
{
A.Current_CTC__c = App.Current_CTC__c + (App.Current_CTC__c * Aps.Increment_Percentage__c);
}
}
AppList.Add(A);
}
}
IF(AppList != NULL)
{
Update AppList;
}
}