This question already has an answer here:

I am trying to query on history object. I want to query records which have specific old value on Lead Status Field.

I have already checked Field can not be filtered in SOQL query call

It is anytype datatype not text area as shown in Image.

enter image description here

Expected SOQL Query is (Query Editor):

SELECT  OldValue,Id, LeadId, CreatedDate FROM LeadHistory Where Field='Status' AND OldValue = 'New'

Error is:

[object Object]: LeadHistory Where Field='Status' AND OldValue = 'New' ^ ERROR at Row:1:Column:84 field 'OldValue' can not be filtered in query call

marked as duplicate by glls, Ratan Paul, Martin Lezer, Santanu Boral, Mohith Shrivastava apex Oct 2 '17 at 2:50

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • It is not a text area type which is described in this. – Kritik Sep 30 '17 at 17:49
  • read further down the post --> check the "filterable" access property of the field – glls Sep 30 '17 at 17:53
  • This isn't even a question. You don't ask anything. The field is not filterable. – Adrian Larson Sep 30 '17 at 17:59
  • Yes you are right. Thanks. So my question is how to filter records based on OldValue ? – Kritik Sep 30 '17 at 18:07
  • For OldValue and NewValue fields filter property is not available, so you can't filter on these fields
  • I don't know what is your business scenario. but if you are sure about you will retrieve less than 50000 records in query. Then possible workaround can be filter records in apex.


 List<LeadHistory> leadHistoryList = new List<LeadHistory>();
    for (LeadHistory lh : [SELECT  OldValue,Id, LeadId, CreatedDate FROM LeadHistory Where Field='Status' LIMIT 50000])
        if(lh.OldValue == 'New')

Not the answer you're looking for? Browse other questions tagged or ask your own question.