Skip to main content
2 of 3
edited tags
Adrian Larson
  • 151.3k
  • 38
  • 247
  • 431

Invalid bind expression type of ANY for column of type Decimal

I know this question has been answered in few places my scenario is a bit different I think.

I'm building a dynamic SOQL query, the WHERE clause is going to be dynamic. I have a List<String> values in which values are stored from VF page using input fields and later this list is used to query records.

My VF page allows users to select fields (these fields will be added to the where clause) on a certain object that will allow them query records. So, Let's say a user selects Age__c field from the VF page which is of type Double and then the user fills in the input fields with Age values.

This is how the query will look like:

SELECT Id, Some_Field__c FROM Some_Object__c WHERE Age__c IN :values

This query fails to execute since the type of Age__c is Double and the collection passed as a filter is List<String>. I then converted this list to a List<Object> and that's when it throws the below error:

Invalid bind expression type of ANY for column of type Decimal

How can I typecast this values list to make this work? How can I solve this issue? Any help will be appreciated.

d_k
  • 1.3k
  • 2
  • 17
  • 40