+ Start a Discussion
JustinWilliams2381JustinWilliams2381 

How to this Visualforce page to my account and contact

I have some apex classes and visualforce pages I received from a consultant for liking their facebook page.  It creates a button on the account and contact that when clicked it displayes the activity history in a grid like fasion instead of the less than visually apealing way it does out of the box.  I have figured out a bunch of problems to get the three classes to save and now I have to get to the page.

 

The visualforce page is below but SF won't allow me to add it to a button on the Account or Contact page.

 

<!--
Copyright (c) 2010, Lexnet Consulting Group, Inc.
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of Lexnet Consulting Group, Inc. nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-->
<apex:page controller="ViewAllActivityController">
<apex:pageBlock title="Activity Details">
<apex:outputText styleClass="leftLabel"><b>&nbsp;Account:</b></apex:outputText>
<apex:outputLink value="/{!Summary.AccountId}" styleClass="leftValue">&nbsp;{!Summary.Account}</apex:outputLink><br />
<apex:outputPanel rendered="{!ShowContactDetail}">
<apex:outputText styleClass="leftLabel"><b>&nbsp;&nbsp;Contact:&nbsp;</b></apex:outputText>
<apex:outputLink value="/{!Summary.ContactId}" styleClass="leftValue">{!Summary.FirstName} {!Summary.LastName}</apex:outputLink><br />
</apex:outputPanel>
</apex:pageBlock>
<apex:pageBlock >
<apex:outputText rendered="{!IF(ActivityHistories.size = 0, true, false)}">No records to display</apex:outputText>
<apex:pageBlockTable value="{!ActivityHistories}" var="ah" rows="{!ActivityHistories.size}" rendered="{!IF(ActivityHistories.size > 0, true, false)}">
<apex:column value="{!ah.Subject}" width="130px" style="vertical-align: top;"/>
<apex:column value="{!ah.ActivityDate}" width="110px" style="vertical-align: top;"/>
<apex:column value="{!ah.Owner.Name}" width="130px" headerValue="Assigned To" style="vertical-align: top;"/>
<apex:column value="{!ah.Who.Name}" width="130px" headerValue="Contact" style="vertical-align: top;"/>
<apex:column value="{!ah.Description}" style="vertical-align: top;"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>

bob_buzzardbob_buzzard

You can only add visualforce pages as these types of buttons if they use the standard controller of the sobject in question.  Thus to use this as an account button, you would need to be using the Account standard controller, but this page has a custom controller.

 

You can make the button target a URL and give it the URL of the apex page.