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
Pierre-EtiennePierre-Etienne 

'&' charater problem in S-Control

I wrote a S-Control to add a button that will create a new contact while passing some additional fields from the Account. The problem is that if the account name has '&' character. When I call the S-control, the Contact created  has the account name truncated. I tried to add single quote or double quote around {!Account.Name} but it did not work. Any idea?

Thanks

<script type="text/javascript" src="/js/functions.js"></script>
<script src="/soap/ajax/12.0/connection.js"></script>

<script language="JavaScript">
function redirect() {

parent.frames.location.replace("/003/e?retURL=%2F{!Account.Id}&con4={!Account.Name}&00N40000001acqc={!Account.Billing_County__c}&CancelURL=%2{!Account.Id}&ent=Contact")
}
redirect();
</script>
canonwcanonw
You need to encode the characters.  Use encodeURIComponent function

Pierre-EtiennePierre-Etienne
Thanks a lot! It worked. Below is the updated code:

<script type="text/javascript" src="/js/functions.js"></script>
<script src="/soap/ajax/12.0/connection.js"></script>

<script language="JavaScript">
function redirect() {
var Act = encodeURIComponent('{!Account.Name}');
parent.frames.location.replace("/003/e?retURL=%2F{!Account.Id}&con4="+Act+"&00N40000001acqc={!Account.Billing_County__c}&CancelURL=%2{!Account.Id}&ent=Contact")
}
redirect();
</script>