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
Doug ACFDoug ACF 

Page Redirect Sandbox vs Production

From a custom detail page button, we want to display a prepopulated Send an Email form.  Forming the email body takes some data queries, so we are using a Visualforce page that onload calls a controller method to assemble the data and then return a PageReference to the emailauthor page with URL parameters.  A Visualforce email template won't work for our use case since it would need to be an HTML template and those aren't editable by the user before sending.


The good news is that this design works fine in sandbox.  However, in production it works sometimes, while other times the emailauthor page displays without any fields populated from the URL parameters.  The behavior is very flaky (for the same record, it will work once, then not the next time, then everytime one day, and none the next day).  It does not appear to dependent on the content/size of the data in the parameters.


Does anyone have an idea why a redirect to emailauthor would work consistently in sandbox and inconsistently in production?

Ron HessRon Hess

I don't have any ideas, but this is not a supported or tested use of emailauthor.jsp, so i'm not too supprised that it's flaky.


Is it because the redirect is from a different domain ( visualforce domain? )

Are you urlencoding the parameters ?


emailauthor could also be ignoring parameters for it's own reasons, so i don't hold much hope for finding a resolution.






Doug ACFDoug ACF

Yep all of the data is getting urlencoded.  We also thought about the domain issue - but that wouldn't seem to explain why it would be shaky in production but fine in sandbox.


The trouble with the "supported" alternative, a Visualforce email template, is that using an <apex:repeat> tag to list related records results in html <span> tags in a text version of the template.  We need the template to be text not HTML since the user needs to further edit the email before sending, and HTML ones are not editable. 


Any other suggestions for an approach that would accomplish our objective?