You need to sign in to do that
Don't have an account?

How to handle double-quotes and single-quotes in a Merge Field
Hi,
I am running into a javascript issue when a specific merge field, Account Name, has both single and double-quotes in its name. So, my sample code looks like:
SControl Code
var accountName = "{!Account_Name}";
After SControl dynamically replaces the Merge Field values
var accountName = "Aethn"a Home Products";
***This causes JavaScript issues as the inner " is not escaped. So I receive a syntax error.
If I wrap the the merge field syntax with single-quotes (var accountName = '{!Account_Name}'), I will resolve the issue for double-quotes within the Account Name, but then I will get errors if a single-quote is in the Account Name.
I have a javascript function that escapes a single-quote and double-quotes, but I can't execute that method since the javascript doesn't even execute due to the syntax error mentioned above.
Question - How can I store a merge field value in javascript that contains BOTH an single-quote and double-quote?
I am running into a javascript issue when a specific merge field, Account Name, has both single and double-quotes in its name. So, my sample code looks like:
SControl Code
var accountName = "{!Account_Name}";
After SControl dynamically replaces the Merge Field values
var accountName = "Aethn"a Home Products";
***This causes JavaScript issues as the inner " is not escaped. So I receive a syntax error.
If I wrap the the merge field syntax with single-quotes (var accountName = '{!Account_Name}'), I will resolve the issue for double-quotes within the Account Name, but then I will get errors if a single-quote is in the Account Name.
I have a javascript function that escapes a single-quote and double-quotes, but I can't execute that method since the javascript doesn't even execute due to the syntax error mentioned above.
Question - How can I store a merge field value in javascript that contains BOTH an single-quote and double-quote?
you have two possibilities:
First, you query salesforce as usual not passing the merge field,
Second, you put your merge field in an hidden div like <div id="hiddenMergeFields"> and you get the value of the innerHTML of the div for further use
Regards