0
Here is my controller class

public class OEM_Target_Controller {

public String currentRecordId {get;set;}
public String parameterValue {get;set;}
public OEM_Target__c oem {get;set;}
public Opportunity_Product_Line_item__c oppProItem {get;set;}

public OEM_Target_Controller(){
    
    //for details in current page section
    
    currentRecordId  = ApexPages.CurrentPage().getparameters().get('id');
     system.debug('currentRecordId' + currentRecordId);
    oem = [select Id, Name,Year__c,Month__c,OEM__c,Product_Category__c,User__c,Target_In_Revenue__c,Target_In_GP__c from OEM_Target__c where id =: currentRecordId ];
    parameterValue = ApexPages.CurrentPage().getparameters().get('name');
    
    //for actual amount and gross profit section
    Id user = oem.User__c;
    string oemVal = oem.OEM__c;
    string year = oem.Year__c;
    string productCategory = oem.Product_Category__c;
    string month = oem.Month__c;
    String stage = 'Won';
    Decimal ToatlAmount=0;
    Decimal GP=0;
    List<String> lstmonth = month.split(';');
    System.debug(lstmonth);
    
    String Query = 'select id ,name ,Opportunity_Name__c , Stage__c,Gross_Profit_Custom__c,Total_Price_Custom__c,OEM__c,Product_Category__c,Vertical_Manager__c,Month__c,Year__c from Opportunity_Product_Line_item__c where OEM__c =:oemVal and Product_Category__c=:productCategory and Year__c=:year and Stage__c=:stage and Month__c IN=:lstmonth ' ;
        System.debug('Query=='+Query);
    
    
    List<Opportunity_Product_Line_item__c> lstoppProItem = Database.query(Query);
     System.debug('lstoppProItem=='+lstoppProItem);
    
      if(lstoppProItem!=null && lstoppProItem.size()>0)
        {
            for(Opportunity_Product_Line_item__c obj :lstoppProItem)
            {
                if(obj.Gross_Profit_Custom__c !=null)
                    GP = GP+ obj.Gross_Profit_Custom__c;
                if(obj.Total_Price_Custom__c !=null)
                    ToatlAmount = ToatlAmount+obj.Total_Price_Custom__c;
            }
        }
    
    system.debug('lstoppProItem'+lstoppProItem);
}

}

I'm facing this error: expecting a colon, found '=' An unexpected error has occurred. Your development organization has been notified. on Query Line

5
  • when are you getting error and what's the exact error? Commented Aug 21, 2020 at 10:53
  • expecting a colon, found '=' An unexpected error has occurred. Your development organization has been notified. Commented Aug 21, 2020 at 10:59
  • 15:42:13:070 EXCEPTION_THROWN [35]|System.QueryException: expecting a colon, found '=' Commented Aug 21, 2020 at 11:00
  • The problem is in your query, remove = after IN, use this query: select id ,name ,Opportunity_Name__c , Stage__c,Gross_Profit_Custom__c,Total_Price_Custom__c,OEM__c,Product_Category__c,Vertical_Manager__c,Month__c,Year__c from Opportunity_Product_Line_item__c where OEM__c =:oemVal and Product_Category__c=:productCategory and Year__c=:year and Stage__c=:stage and Month__c IN: lstmonth Commented Aug 21, 2020 at 11:04
  • Yes thanks a lot!! It works.. Commented Aug 21, 2020 at 11:10

1 Answer 1

0

The problem is in your query, remove = after IN.

Use below query:

select id ,name ,Opportunity_Name__c , Stage__c,Gross_Profit_Custom__c,Total_Price_Custom__c,OEM__c,Product_Category__c,Vertical_Manager__c,Month__c,Year__c from Opportunity_Product_Line_item__c where OEM__c =:oemVal and Product_Category__c=:productCategory and Year__c=:year and Stage__c=:stage and Month__c IN: lstmonth

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .