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

Help needed attaching a visualpage to a custom button on Event

I'm trying to mimic creating a New Event from the related list section (Open Activities) on Opportunity page through a custom button (called "New Event X"). This custom button, on clicking, should open a visualpage in edit mode. This visualpage is based on a standard controller for Event, has fields from Event and a few other objects.

Here's the problem- I have the visualpage created, but can't attach it to the custom button because the button type is "List Button" and the page is based on a standard controller for Event. If I change the button type to Detail Page Button then I can attach the visualpage to it, but Salesforce requires the custom button to be of "List Button" type in order for it to appear on the related list section of Opportunity page.

I don't want to override the standard button "New Event". It seems like a pretty common requirement, and I'm wondering how others have done it.

Any help would be much appreciated. Thanks in advance.



Best Answer chosen by Admin (Salesforce Developers) 
Why not use a URL type button instead?

All Answers




   Make a content source of list button is  'On click javascript' instead of Visualforce page


write code: window.location.href = '/apex/urVFpage?lkid={!Opportunity.Id}';

Why not use a URL type button instead?
This was selected as the best answer
Thats great. Thank you, both. Will try that.

Resurrecting an older thread.  I've had the exact same problem, trying to put a custom button on a related list.  I've tried making the VF page and class of type list, using setRecordVar, but that can't be done with the "Task" object.  I came up with the URL button solution, which works great, until I try and put things in managed packages.  Then the VF page can't be found.  This behavior is consistent with the description of things here:


Previous Packaged URL button discussion 


So, I'm stuck between two problems.  On the one hand, using a pure VF page is seemingly impossible on the "Activity History" list, and on the other, a URL work-around seems to break when it comes time to make managed packages.


Any input here?