Here is how to create a URL-based Web Link, the variety that works in both Classic and Lightning Experience. The steps are nearly identical for a button; you only change the display type.
- Open the object in Setup
Go to Setup, Object Manager, and pick the object (for example Account). Click Buttons, Links, and Actions, then New Button or Link.
- Set label, name, and display type
Enter a Label and let the API Name auto-fill. Choose a display type: Detail Page Link, Detail Page Button, or List Button.
- Choose URL as the content source
Set Behavior (for example Display in new window) and Content Source to URL. URL keeps the link working in Lightning Experience.
- Build the URL with merge fields
Type the target address and insert merge fields from the picker, such as {!Account.Id} or {!Account.Name}, to pass record context.
- Save and add it to the layout
Click Save, then open the relevant Page Layout (or related list) and drag the new link or button into place so users can see it.
The user-facing text for the link or button.
The unique developer name; auto-generated from the label and used in metadata.
Detail Page Link, Detail Page Button, or List Button.
URL, OnClick JavaScript (Classic only), or Visualforce Page.
How the target opens, such as a new window or the existing window with or without the sidebar.
- A new link is invisible until you add it to a page layout or related list; creating it is only half the job.
- OnClick JavaScript links do not appear in Lightning Experience at all, so never use that content source for a Lightning org.
- URL parameter prefill tricks (URL hacking) that worked in Classic are unsupported in Lightning; use a Quick Action or Flow instead.
- List buttons that act on multiple records need Display Checkboxes (row selection) enabled, or users have nothing to select.