1

I'm using the Salesforce ruby gem to do the following

@client.search("FIND {#{@email}}")

@email returns the user's email address. During testing, I had an email address like test+test@example.com and this caused a MALFORMED_SEARCH error. I tried calling to_json on the email, but that didn't fix it. What kind of escaping should I be doing here? Is there a generic way to do this?

I'd like to avoid escaping specific characters like '+', but if that's necessary, I understand. I just don't know what that list of invalid characters is.

I guess a more specific question is: how do I make sure that any query I pass into FIND won't return a MALFORMED_SEARCH error because of invalid characters or something like that?

Thanks!

[EDIT] It seems that the plus sign is the only issue here... Is there any documentation that enumerates other symbols that might be an issue?

1

The + symbol is reserved in SOQL, this is covered in the documentation along with the other reserved characters:

The following characters are reserved:
? & | ! { } [ ] ( ) ^ ~ * : \ " ' + -

Reserved characters, if specified in a text search, must be escaped (preceded by the backslash \ character) in order to be properly interpreted. An error occurs if you do not precede reserved characters with a backslash. This is true even if the SearchQuery is enclosed in double quotes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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