function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
keerthana chowdharykeerthana chowdhary 

line 10:91 no viable alternative at character '_'

trigger percantageupdate on appraisal__c (after insert,after update)
{
 set<id> sd = new set<id>();
for (appraisal__c  a :trigger.new)    
{
    sd.add(a.appointments__c);
    
}
    list<appointments__c> app= new list<appointments__c>();
    app=[select id,of_increment__c,amount_increment__c,(select id,ctc__c from appraisal__c __r) from appointments__c where id IN: sd];
    for(appointments__c c: app )
    {
        c.of_increment__c=c.ctc__c;
        c.amount_increment__c=c.ctc__c;
    }
    update app;
}

help me urgent
Amit Chaudhary 8Amit Chaudhary 8
Please try below code. I hope that will help you
rigger percantageupdate on appraisal__c (after insert,after update)
{
 set<id> sd = new set<id>();
for (appraisal__c  a :trigger.new)    
{
    sd.add(a.appointments__c);
    
}
    list<appointments__c> app= new list<appointments__c>();
    app=[select id,of_increment__c,amount_increment__c,(select id,ctc__c from appraisal__r ) from appointments__c where id IN: sd];
    for(appointments__c c: app )
    {
        c.of_increment__c=c.ctc__c;
        c.amount_increment__c=c.ctc__c;
    }
    update app;
}
Please check your child relationship Name it should be  appraisal__r  or  appraisals__r . To chek right Name please click on Lookup relationship and check child relationship name
 
Gyanender SinghGyanender Singh
Hi keerthana chowdhary

app=[select id,of_increment__c,amount_increment__c,(select id,ctc__c from appraisal__c __r) from appointments__c where id IN: sd];

in place of appraisal__c __r write child relationship name.

Thanks 
Gyani
ManojjenaManojjena
Hi Keerthana,

Gyanendra is right you need to check the relationship name ,Also you need to check one more thing you can not access child object field directly with parent object varibale from inner query .

Check below code  how ever you need to check the relationship name and child object count .
 
trigger percantageupdate on appraisal__c (after insert,after update){
	Set<id> appIdSet = new Set<id>();
	for (appraisal__c  apr :trigger.new){
	   if(apr.appointments__c != null){
		   appIdSet.add(apr.appointments__c);
	   }
	}
    if(!appIdSet.isEmpty()){
	    List<appointments__c> listOfApmtToupdate=new List<appointments__c>();
		 for(appointments__c  apmt : [SELECT id,of_increment__c,amount_increment__c,(SELECT id,ctc__c FROM appraisal__r ) FROM appointments__c WHERE  Id IN: appIdSet]){
			if(!apmt.appraisal__r.isEmpty()){
			   //Here you will get list of Apprisal which record ctc__c you want to assign to of_increment__c and amount_increment__c.
			   if ypu think only one record should there then you can go with below code  .
				ampt.of_increment__c=apmt.appraisal__r[0].ctc__c;
				ampt.amount_increment__c=apmt.appraisal__r[0].ctc__c;
				listOfApmtToupdate.add(ampt);
			}
	    }
		try{
		   update listOfApmtToupdate;
		}catch(DmlException de ){
		  System.debug(de);
		}
    }
}
Let me know if it helps !!
Thanks
Manoj