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
GnaneswarGnaneswar 

How to add a custom Detail Page Javascript Button on Visualforce page?

Hi All,

I created a simple custom button which executes javascript onclick of it. How to add this button to Visualforce page to execute this button?

Thanks in advance!
Rajiv Bhatt 16Rajiv Bhatt 16
Here is what you need to add in your VF Page, replace the CustomObjectName__c with the object name on which the button is created and Custom_Button_Name__c with the name of the custom button that you created:  
<apex:commandButton action="{!URLFOR($Action.CustomObjectName__c.Custom_Button_Name__c, Id)}" id="Button" value="Button"/>

 
GnaneswarGnaneswar
I added a button which executes Javascript. Above command button works if content source of the custom button is Visualforce page. But, content source of my button is Javascript. The above commandButton gives me below error on the page.
"URL No Longer Exists"
Is there any other way to do this?
NinetaMNinetaM
I am running into the same issue. Is it even possible to add a JavaScript custom button and have it work from a Visualforce page?
Tom Blamire 24Tom Blamire 24
anyone worked out how to resolve this?
Jeffrey CheungJeffrey Cheung
And 2 years later is there anyone can answer? Any Salesforce staff please come out and answer. SMH