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
Raju I 5Raju I 5 

Error: Compile Error: expecting a semi-colon, found 'for' at line 10 column 19 when i am compering two object in if condition.if both same then it fallow as code

trigger  test on Account (before insert, before update,after insert)
{  
List<Customer_Info_Form__c> lst = new List<Customer_Info_Form__c>();
        for(Account acc : trigger.new){
        
             list<Customer_Info_Form__c> con= [ select  Contact_Number__c,Email__c, Customer_Account__r.Name from  Customer_Info_Form__c where
  id in:trigger.new]
                   //Customer_Info_Form__c con = new Customer_Info_Form__c();
                   
                   for(Customer_Info_Form__c c1 : con)
                   {
                        if(Customer_Account__r.Name== acc.Name )
                         {
     
                       c1.Contact_Number__c = acc.PersonMobilePhone;
                       
                         c1.Email__c = acc.CG_Email_ID__c;
                     }
                        con.add(lst) ;
                       
            
        update  lst;
       
      
       }
       }
Ravi Dutt SharmaRavi Dutt Sharma
Hey Raju,

Try below code :
 
trigger  test on Account (before insert, before update,after insert)
{  
List<Customer_Info_Form__c> lst = new List<Customer_Info_Form__c>();
        for(Account acc : trigger.new){
        
             list<Customer_Info_Form__c> con= [ select  Contact_Number__c,Email__c, Customer_Account__r.Name from  Customer_Info_Form__c where
  id in:trigger.new];
                   
                   for(Customer_Info_Form__c c1 : con)
                   {
                        if(c1.Customer_Account__r.Name== acc.Name )
                         {
     
                       c1.Contact_Number__c = acc.PersonMobilePhone;
                       
                         c1.Email__c = acc.CG_Email_ID__c;
                     }
                        con.add(lst) ;
                       
            
        update  lst;
       
      
       }
       }

 
Raju I 5Raju I 5
thanks for quick reply but i am getting other error Error: Compile Error: Invalid bind expression type of Account for Id field of SObject Customer_Info_Form__c at line 7 column 9
Raju I 5Raju I 5
i am not getting please clear on trhis
Ravi Dutt SharmaRavi Dutt Sharma
Your query seems to be wrong. Trigger.new will contain account id's, not Customer_Info_Form__c id's.
Raju I 5Raju I 5
now my query is: list con= [ select Contact_Number__c,Email__c, Customer_Account__r.Name from Customer_Info_Form__c where id IN:acc.id]; but getting error Error Error: Compile Error: IN operator must be used with an iterable expression at line 8 column 9
Ravi Dutt SharmaRavi Dutt Sharma
Hey Raju,

Please try below code :
 
trigger  test on Account (before insert, before update,after insert)
{  
List<Customer_Info_Form__c> lst = new List<Customer_Info_Form__c>();

Set<Id> accIdSet = new Set<Id>();
for(Account acc : Trigger.new){
	accIdSet.add(acc.Id);
}

        for(Account acc : trigger.new){
        
             List<Customer_Info_Form__c> con= [SELECT Contact_Number__c,Email__c, Customer_Account__r.Name FROM  Customer_Info_Form__c WHERE Id in:accIdSet];
                   
                   for(Customer_Info_Form__c c1 : con)
                   {
                        if(c1.Customer_Account__r.Name== acc.Name )
                         {
     
                       c1.Contact_Number__c = acc.PersonMobilePhone;
                       
                         c1.Email__c = acc.CG_Email_ID__c;
                     }
                        con.add(lst) ;
                       
            
        update  lst;
       
      
       }
       }