[SalesForce] Invalid bind expression type of Integer for column of type String

 Integer BPcurrentYear = System.Today().year();
    List<Business_Plan__c> lBPs = [Select b.Year__c,  b.FCPA_Last_Updated__c, 
        (Select Name,IsHQ__c 
        FROM Business_Plan_Details__r WHERE Type__c = 'Current Year Revenue Goal') 
        FROM Business_Plan__c b WHERE Partner_Account__c = :accInstance.Id and b.Status__c = 'Approved' AND b.Year__c = :BPcurrentYear
        ORDER BY b.Year__c DESC ];

From abive query i'm getting error:

Invalid bind expression type of Integer for column of type String

I'm having problem with b.Year__c = :BPcurrentYear

Here the b.Year__c is Text Field. I am comparing with integer.

How to compare the Text field with integer or should i take take Current year in any other format which can assign to Text field?

Best Answer

You need to pass String value for Year__c field:

String BPcurrentYear= String.valueOf(system.today().year());

Related Topic