1

Hi stackexchange community.

I have noticed that the e-mail template i've been using somehow cuts the rest of the address in "Additional To" field, if it contains "&" sign (e.g. test&[email protected] will look like "test" in the template).

I have a field in my Account page, which is the email address, and this is the javascript code for the button:

{!requireScript("/soap/ajax/26.0/connection.js")} 

var account = new sforce.SObject("Account"); 

account.id = "{!Account.Id}"; 

if ("{!Account.Obj1__c}" == "Yes") 
{ 
window.open('/email/author/emailauthor.jsp?retURL=/{!Account.Id}&p3_lkid={!Account.Id}&rtype=003&p2_lkid={!Case.ContactId}}&p24={!Account.Obj1_Email__c}&retURL={!Account.Id}&template_id=00XD0000001dNl9','Popup','height=800,width=800,left=100,top=100,scrollbars=yes,toolbar=no,status=no'); 
} 
else 
{ 
window.open('/email/author/emailauthor.jsp?retURL=/{!Account.Id}&p3_lkid={!Account.Id}&rtype=003&p2_lkid={!Case.ContactId}}&p24={!Account.Obj2_Email__c}&retURL={!Account.Id}&template_id=00XD0000001vGzq','Popup','height=800,width=800,left=100,top=100,scrollbars=yes,toolbar=no,status=no'); 
} 

sforce.connection.update([account]);

I'd really appreciate if you could advise me how to deal with this issue.

Thanks in advance and best regards

1 Answer 1

2

I am going to go out on a limb and assume the custom field you are talking about is Account.Obj1_email__c and Account.Obj2_email__c, and the input for your form is ...&p24={!Account.Obj2_Email__c}&retURL...

When building a URL, there are several reserved characters for different purposes. the & character is a parameter deliminator.

Because you are not escaping the & in the email address, it is assigning what comes before it to p24 and then creating a new parameter with what ever comes after.

I think you simply need to URLENCODE() the email address, and you will see what you are expecting

3
  • Hi Tezyn! Thank you for your answer! Your assumption re field names is correct. Also, the e-mail field is based on customers name, so it's not a direct input, but a formula, like IF(Current_Customer__r.Name = "Test", "test&[email protected]",. Re your suggestion, i'm not really sure how can i do that. Shall i update the e-mail field formula to IF(Current_Customer__r.Name = "Test", URLENCODE("test&[email protected]"),? Or do i need to update &p24={!Account.Obj2_Email__c} to &p24=URLENCODE({!Account.Obj2_Email__c}). Thank you in advance for your help
    – Echo_2
    Feb 6, 2015 at 13:11
  • &p24={!URLENCODE(Account.Obj2_Email__c)} Be sure to also change the reference to Account.Obj1_Email__c in the lines above.
    – Tezyn
    Feb 6, 2015 at 13:25
  • Hi Tezyn, it worked like a charm! Thank you so much for helping me out!
    – Echo_2
    Feb 6, 2015 at 13:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .