4

I'm trying to get my Escape characters to work in Force.com explorer.

This is exactly what the data looks like in Salesforce,

Awaiting Custodian Data - Pending '8'

I need to filter in on this data with a query statement like this,

Where policy__r.Policy_Status__c = 'Awaiting Custodian Data - Pending '8''

Here is what I have tried but I cannot get to work,

'Awaiting Custodian Data - Pending \'8\''

'Awaiting Custodian Data - Pending ''8'''

'Awaiting Custodian Data - Pending \'\8\'\'

'Awaiting Custodian Data - Pending '8''

"Awaiting Custodian Data - Pending \'8\'"

I can't figure out whats not working here, any one got an idea?

Bryan Harrington
  • 991
  • 2
  • 17
  • 31

1 Answers1

5

SOQL requires the ' be escaped with \, which would get you to

where policy__r.policy_status__c='awaiting custodian data - pending \'8\''

(which works for from the soap api), if you're building this string in apex, then \' is also an escape sequence in apex so you'd need to escape that to something like \\\'8\\\'

superfell
  • 18,780
  • 4
  • 59
  • 81