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
Prasanth Reddy MPrasanth Reddy M 

Custom button is not Working ?

Hi,

Got "Account Hierarchy" custom  button in "App Shark Account Hierarchy" Package.

The button is working fine in standard page Account layouts, but when tried to use in VF with below code, it is showing 'URL No longer exists'

<apex:commandButton onclick="window.open('/apex/AppShark_AH__Account_Hierarchy?id={!Account.id}','Account Hiererchy', '_blank');" styleClass="buttonStyle" style="background:White;width:90px;" value="Account Hierarchy" immediate="true"/> 

How can i fix this ?
Best Answer chosen by Prasanth Reddy M
pconpcon
So that is not the same URL you have in your commandButton.  If you update your command button to be:
 
<apex:commandButton
    onclick="window.open('/apex/AccountHierarchy?id={!Account.id}','Account Hiererchy', '_blank');"
    styleClass="buttonStyle"
    style="background:White;width:90px;"
    value="Account Hierarchy"
    immediate="true"/>

All Answers

pconpcon
What does your button look like that you use on your standard page?  is it just a link button?
Prasanth Reddy MPrasanth Reddy M
The button, on clicking opens below visualforce page.
https://appshark-ah.cs24.visual.force.com/apex/AccountHierarchy?scontrolCaching=1&id=0011900000Bjt2I
 
pconpcon
So that is not the same URL you have in your commandButton.  If you update your command button to be:
 
<apex:commandButton
    onclick="window.open('/apex/AccountHierarchy?id={!Account.id}','Account Hiererchy', '_blank');"
    styleClass="buttonStyle"
    style="background:White;width:90px;"
    value="Account Hierarchy"
    immediate="true"/>
This was selected as the best answer
Prasanth Reddy MPrasanth Reddy M
I have added the namespace in the above code, it worked. 

Thx.