function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
RoscoeRoscoe 

Error using encodeURIComponent() in s-Control

I am unable to use encodeURIComponent() function in s-Control - it is failing when I declare the variable as follows:

var strBillingAddress = encodeURIComponent({!Account.BillingAddress});

Any help is greatly appreciated!

Thank you

werewolfwerewolf
Put the merge field in quotes.  As it is, if you run it in Firebug you'll see that these merge fields evaluate to an absolute, so it looks to the JS parser like:

var strBillingAddress = encodeURIComponent(123 Main St.);

Which it doesn't know how to deal with.  Instead, put single quotes around the merge field like this:

var strBillingAddress = encodeURIComponent('{!Account.BillingAddress}');

And it will resolve to:

var strBillingAddress = encodeURIComponent('123 Main St.');

Which is what you want.