You need to sign in to do that
Don't have an account?
ricohusa
how to deal with special characters in opportunity name
Hi,
I have a question about use special characters in opportunity name:
I created an opportunity which has double quotation " and the prime ', the name is:
special"ABC'123/\*
Now I want to use this name in my S-Control which is using HTML code, actually
I want to remove the speical characters, to make it as
specialABC123
But if I put the above string in a Javascript function like this:
var str = "{!Opportunity.name}" or var str = '{!Opportunity.name}'
Since {!Opportunity.name} only replaces the whole string directly
without encoded or escaped, the string is like this:
"special"ABC'123/\*" or 'special"ABC'123/\*'
None of them could work properly because either the double quotation " should be
escaped as \" or the prime should be escaped as \' to make the Javasrcipt string
as a valid string.
Does anybody know how to use the opportunity name string as encoded or escaped?
The only way I know how to use it is:
{!Opportunity.name}
but this does not work properly in the above case.
Thanks.
Method 1: Use retrieve()
Method 2: Use Substitute() (repeatedly)
This should work for any name, as it escapes the escape character, and also escapes double-quotes. You should escape single quotes if you prefer to mark your strings with single quotes instead.
Honestly, some developer in Salesforce needs to make it so S-Controls automatically escape quotes like my formula above does. And line breaks, too.
I've run into this a few times but haven't had a fix. This is great.