4

Afternoon all,

I have a custom button on my Opportunity object to Onclick Execute Javascript to send an email to a specific email address, code below:

{!REQUIRESCRIPT("/soap/ajax/27.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/10.0/apex.js")} 

var newRecords = [];
var c = new sforce.SObject("Opportunity");
c.id ="{!Opportunity.Id}";
c.PMO_Request_Submitted__c = true;
newRecords.push(c);
result = sforce.connection.update(newRecords);
window.location.reload();

location.replace('/email/author/emailauthor.jsp?retURL=/{!Opportunity.Id}&p3_lkid={!Opportunity.Id}&p24=PMO-IT%[email protected]&template_id=00Xb0000000e3nq&p5=');

It works absolutely fine for me as an Admin but when my users try and use it the field changes occur and the Opp page refreshes but it doesn't launch the Send Email page. Is there a particular permission that needs enabling to allow this functionality to be used?

9
  • Does your page is accessible for your users ? You can check that in Setup > Permissions set > Pages
    – SF_user
    Apr 24, 2015 at 11:56
  • I've access that section but I don't have a Pages permission set. Have I missed setting something up?
    – CaptainHaZ
    Apr 24, 2015 at 12:51
  • The whole path is : Setup > Manage users > Permission Sets
    – SF_user
    Apr 24, 2015 at 12:53
  • Yep, and I'm in there now. There are permissions sets for other aspects of my org but nothing related to Emails or Opportunities or JavaScript. Have I missed something?
    – CaptainHaZ
    Apr 24, 2015 at 13:02
  • You said but it doesn't launch the Send Email page. Do you have this page allowed for your user ? You have a section VisualForce pages in the dropdown list.
    – SF_user
    Apr 24, 2015 at 13:10

1 Answer 1

1

Assuming your intent is simply to navigate to the email editor in the same window, remove this line:

window.location.reload();

In Internet Explorer, any navigation immediately cancels the currently running script, fires the onbeforeunload and onunload events, then navigates. Other modern browsers discard any prior navigation event, which is the same behavior you'd expect if you clicked on multiple bookmarks in your toolbar in rapid succession-- only the last bookmark clicked on would be navigated to.

You must log in to answer this question.

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