5

I want to hide a standard or custom salesforce button on standard page. I don't want to use record type based layout to do that.

3
  • 2
    It is not possible with a standard salesforce resources. If you have an "onclick javascript" button you could implement some validation based on the field value. – Sergej Utko Apr 14 '15 at 7:06
  • Can I run a script on load of a standard page? – Mehebub Hossain Apr 14 '15 at 10:57
  • 2
    You can override VF page using <apex:detail /> and than create JS function to hide or show a button with window.onload function. – Simon Apr 14 '15 at 12:43
2

A workaround could be to create a hyperlink formula with an image of a button, although it would not be located with the other buttons. See help article here with a how to:

Knowledge Article Number: 000004375
Resolution

  1. First, save the button image in a public document folder. To do this, go to the Documents tab and click New. Enter the name of the document, select the “Externally Available Image” option, and select the public folder to place the image. The Description and Keywords fields are optional. Browse for the file and save it. null nullCreate a TEXT formula field. To do this, go to Setup – App Setup – Customize – Accounts (or the object where you are going to place the field) – Fields. And click on New on the Account Custom Fields and Relationships section. null nullFor Custom Objects, go to Setup – App Setup – Create – Objects – Click on the label of the object and click on the New button on the Custom Fields and Relationships section.

  2. When selecting the Field Data Type, select “Formula” and click on Next. Enter a name for the field and for the Formula Type select “Text”, click on Next.

  3. When being asked to build the formula, write the text formula using the HYPERLINK and IMAGE functions. In this example, the formula adds a button that when clicked from the Account record, launches a search on Leads where “Company” matches “Account Name”, using the image saved in the Documents folder to be the button. null nullTo build this formula you will have to first ensure you are under the “Advanced Formula” sub-tab; select the HYPERLINK function and click on the “Insert Selected Function” button. null nullThis will place the function in the formula editor in the form of HYPERLINK(url, friendly_name [, target]). null nullOnce you have it like that, replace the ‘url’ part with the address of the lead search results page. null nullTo obtain the right url, go to any tab with the sidebar visible, on the search drop-down, select Leads and click Go! (there is no need to type anything). You will be at the results page with an error saying you need at least 2 characters long for the search. The url on the address bar of your browser will be something like https://.salesforce.com/search/SearchResults?searchType=1&sen=00Q&setLast=1&sbstr=&search=+Go%21+, where the ‘’ is your instance. null nullCopy everything after the ‘.com’ and paste it instead of the ‘url’ part in the formula. Then, divide this address in two parts and enclose them with quotation marks where the first one is “/search/SearchResults?searchType=1&sen=00Q&setLast=1&sbstr=”; and the other one “&search=+Go%21+”. Type in ‘& Name &’ (which references the Account Name) in the middle of the two parts, so you will now have something like this: HYPERLINK("/search/SearchResults?searchType=1&sen=00Q&setLast=1&sbstr=" & Name & "&search=+Go%21+", friendly_name [, target]) (with the quotations).

  4. Next, replace the ‘friendly_name’ part with the IMAGE function. To insert it follow the same steps followed to insert the HYPERLINK function. This will place ‘IMAGE(image_url, alternate_text [, height, width])’ in the editor. So in this case you have to replace the ‘image_url’ with the url of the image saved in the Documents tab. null nullTo obtain it, go to the Documents tab and open the button image. Right-click in the image and select “Properties”. Then copy the Address URL after the ‘.com’ and paste it in the IMAGE function enclosed with quotation marks. null nullIt is very important you make sure you copy it completely.

  5. Next, you will have to replace the ‘alternate_text’ with something that will let you know what this button will do; it will be visible when you hover your mouse over the button. In this example we are entering “Search for Leads” (with quotation marks), but you can enter anything you want.

  6. Now, the ‘[, height, width]’ and the ‘[, target]’ parts are optional. The first one is to set the dimensions of how the image will look, in pixels. The other one is to specify how the link will open when clicked, it can be either in a new window or on top of the current window. For additional information on these and other functions, see “Operators and Functions” in Help & Training.

In our example, we are not using those two parts, so just delete them. This will leave us the formula like the following:

HYPERLINK("/search/SearchResults?searchType=1&sen=00Q&setLast=1&sbstr=" & Name & "&search=+Go%21+", IMAGE("/servlet/servlet.ImageServer?id=01530000001Fmb3&oid=00D30000000ehPe&lastMod=1276195061000", "Search For Leads"))
  1. Click on Check Syntax to make sure the formula is correct.

If so, click on Next and follow the rest of the steps of the creation wizard, which may differ depending on your Edition, and save it.

  1. Once saved, you will have the field showing in any account details page. If it is clicked, a window will open with a Search of Leads by Company name.
1
  • 1
    This is our standard approach to this problem – Adrian Larson Jun 3 '15 at 0:12
-1

Yes it is possible. For that you have to follow the steps.

  1. Add one boolean property in your class.

    public Boolean visible { get; set; }

  2. Now assign this value to rendered attribute of your button.

<apex:commandButton id="btntest" value="My button" rendered="{!visible}"/>

  1. Now add your condition of field on which you want to set visibility of button.

like ,

visible=True; By default button will be visible.

if(your condition ) {

visible=false; **//if you condition satisfied then button will be hide**

}

1
  • No I want to hide a Button on Standard page. – Mehebub Hossain Apr 15 '15 at 6:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.