5

I am querying in the Workbench with SOQL. I need to query a history object to a custom field, but I want to see changes only to a certain field. What is the syntax to say WHERE Field = MyTargetField ?

I tried this:

SELECT Field, NewValue, OldValue 
FROM MyCustomObject__History
WHERE Field = myTargetField__c

but this generates an error:

MALFORMED_QUERY:
WHERE Field = myTargetField__c

ERROR at Row:3:Column:14
Bind variables only allowed in Apex code

1
  • Just a note, whenever you get an error message you should include its text verbatim.
    – Adrian Larson
    Commented Apr 18, 2017 at 0:42

1 Answer 1

3

You need to wrap the value in single quotes ('...'):

SELECT Field, OldValue, NewValue
FROM MyObject__History
WHERE Field = 'Custom_Field__c'
4
  • I tried that, and that returns empty, it does not match with my target field.
    – ALisboa
    Commented Apr 18, 2017 at 0:50
  • @ASignor Are you sure you actually have history records where that field has changed?
    – Adrian Larson
    Commented Apr 18, 2017 at 0:51
  • Actually I'm not. You are probably right. Thank you.
    – ALisboa
    Commented Apr 18, 2017 at 0:52
  • Easy enough to verify. Just change the value in that field on an existing record. :)
    – Adrian Larson
    Commented Apr 18, 2017 at 0:55

You must log in to answer this question.

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