Print this page

How do I create a custom button to appear in a field?

Knowledge Article Number 000004375
Description To create a custom button as a custom field (example using the Account Object):


  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.
    • ​​Create 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.
    • For 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.
    • ​​To 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.
    • This will place the function in the formula editor in the form of HYPERLINK(url, friendly_name [, target]).
    • Once you have it like that, replace the ‘url’ part with the address of the lead search results page.
    • To 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://*, where the ‘*’ is your instance.
    • Copy 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.
    • To 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.
    • It 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"))
  7. 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. 
  8. 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.

promote demote