I am developing a Salesforce integration for a Rails application and I ran into an issue of searching/submitting contacts with emails that include special characters like '+'.
Within the Salesforce documentation, they mention that some characters are reserved and a '\' needs to be inserted before each reserved character. Details: https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_sosl_find.htm
Given that a '\' is used to escape characters in Ruby, I have not been able to add the '\' to a reserved character without running into issues with the Salesforce API. For those who have implemented a Salesforce integration for Rails, how did you solve the issue of reserved characters within emails? Thanks!
You should escape special characters ? & | ! { } [ ] ( ) ^ ~ * : \ " ' + - in your string like this
"[email protected]".gsub(/(\?|&|\||\!|\{|\}|\[|\]|\(|\)|\^|\~|\*|\:|\\|\"|\'|\+|\-)/){|special| "\\" + special }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With