You need to sign in to do that
Don't have an account?
URL encoding merge fields in S-Controls
I have a rather sticky problem with double quotes and opportunity names.
When a person uses a double quote, logic in a custom S-Control does not work because there is string concatenation within some java script.
This happens because the java script contains merge fields where are essentially plugged into the java script before that java script is sent to the client browser.
parent.frames.location.replace(“http://www.somenewsite.com?oppname= “ + escape(“{!Opportunity_Name}”));
If the opportunity name happens to include a double quote this function will not work. Any other invalid character will be replaced by the java script ‘escape’ function. To see why this happens look at the two following examples.
EXAMPLE 1
Opportunity name: Opportunity1
Resulting Java script after merge field applied by SFDC.
parent.frames.location.replace(“http://www.somenewsite.com?oppname= “ + escape(“Opportunity1”));
EXAMPLE 2
Opportunity name: Opportunity “2”
Resulting Java script after merge field applied by SFDC.
parent.frames.location.replace(“http://www.somenewsite.com?oppname= “ + escape(“Opportunity “2””));
As you can see the second example contains invalid java script syntax and will cause an error.
How can I encode the result coming from the SFDC merge field?
Currently I use a validation rule on the opportunity:
OR(CONTAINS( Name , "\""),CONTAINS( Name , "'"))
But I would rather allow double quotes
Any ideas?
~ sfdcfox ~