1

We use a URL hack in a JavaScript button to set the From field on Email Messages based on a custom field on the Case. The hack is:

location.replace('/email/author/emailauthor.jsp?retURL=/{!Case.Id}&p3_lkid={!Case.Id}&rtype=003&p2_lkid={!Case.ContactId}&p26={!Case.From_Email__c}')

All the replacements work except for the final one &p26={!Case.From_Email__c} and it only fails for one user.

I can see the correct dynamic values in the URL in the browser including the email address but the email address that appears in the From field is not from the URL. When there is only text (a "no email found" value) in the URL instead of an email address, the replacement works for this user.

I've tested the behavior logged in as a user with the exact same Profile on the exact same Cases: The URL replaces the From email correctly as expected.

The URL is built from the Salesforce-provided one that is seen on the Emails related list on Cases, with the addition of the From field, p26.

<label for="p26"><span class="assistiveText">*</span>From</label></td><td class="data2Col" colspan="3"><div class="requiredInput"><div class="requiredBlock"></div><select  id="p26" name="p26">

I do also see that the email in the URL does appear as the selected option value but the displayed text is different.

<option value="[email protected]" selected="selected">&quot;Another Address&quot; &lt;[email protected]&gt;</option>

Any suggestions about what could cause this for just one user and only for email addresses? Other ways to test this or trap the error?

2
  • If the email is started other than by the button, does the user have the email addy available for selection? I've been messing with p26 a bit myself - are you populating it with an org-wide address, or an e-mail-to-case address? It has to come through with the same colon-delimited formatting as you see from inspecting the From selector in your browser, eg, 0D270000000gyVTBAZ:[email protected]:Luke FTW for a org-wide or [email protected]:Luke FTW for a e2c. And for org wide, requires permission, of course. Feb 5, 2018 at 19:44
  • 1
    The email address is available in the From picklist to the user, and they are Org. Wide Email Addresses to which the user has access. If there were some formatting issue, I would expect it to affect all other users in the same way. I haven't tested every user but I have tested this with several others on dozens of Cases and this is the only use affected. Feb 5, 2018 at 19:50

1 Answer 1

2

I've got a solution but no real explanation why this happens.

When I examined the HTML for the failing user versus a non-failing user I noted that the failing user had one extra option in the From select list. Their user email was duplicated but one had a different name:

<select  id="p26" name="p26">>
<option value="[email protected]:A User">&quot;A User&quot; &lt;[email protected]&gt;</option>
<option value="[email protected]:A- Technical Support">&quot;A- Technical Support&quot; &lt;[email protected]&gt;</option>

I traced that back to Setup > Email > My Email Settings for the failing user and noted that the Email Name was "A- Technical Support". I changed that to the First Name Last Name value from the user's account record.

After this change the email replacement from the URL to the From field worked as expected.

Looking more closely at the pattern of failures it was apparent that the picklist, when failing, was using the value above the expected one. It's as though it attempted to choose value #10 but because there was one extra entry due to the Email Setting, #10 was now #11.

So I can only explain what happened, not why but at least how to fix it.

2
  • If anyone has a solution that allows users to set their own Email Name in Email Settings and still apply the URL hack to correctly override the From field on Emails, I will eagerly and happily make that the Best Answer! Feb 5, 2018 at 22:22
  • I think the "correct" fix is to move away from URL hacking and instead use the QuickActionDefaultsHandler Interface in an Action, but obviously there's a lot of configuration and training that goes along with that. Feb 6, 2018 at 14:15

You must log in to answer this question.

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