WebLink defines an object-scoped custom button or link as a subcomponent of CustomObject metadata. It specifies the content invoked when a user clicks the button or link and how that content opens.
The definition, its placement in the interface, and its target content are separate. For example, a Layout can reference a WebLink that targets a Visualforce page. Creating the WebLink does not, by itself, place it on a layout or another interface surface.
Key Elements
| Element | What the Element Controls |
|---|---|
fullName |
Deployment identity. Use an object-qualified name such as MyObject__c.MyButton for component-level operations, and the local name MyButton inside the containing object definition. Required when creating, updating, or deleting. |
availability |
Required availability setting: online for online only, or offline for online and offline availability. |
displayType |
Rendering and placement category: link, button, or massActionButton. A massActionButton is attached to a related list. |
linkType |
Required content source: url, javascript, page, or sControl. The enumerated value flow is reserved for future use. |
url |
The destination URL when linkType is url, or JavaScript code when it is javascript. Content must follow XML escaping rules. Leave empty for other content sources. |
page |
The Visualforce page, represented by ApexPage metadata, when linkType is page. Leave empty otherwise. |
scontrol |
The Scontrol name when linkType is sControl. Leave empty otherwise. The capitalization differs between the element name and the enumerated value. |
encodingKey |
Required encoding setting for URL content. The default is UTF-8. Character encoding is separate from XML escaping. |
openType |
Required opening behavior: newWindow, sidebar, noSidebar, replace, or onClickJavaScript. This is separate from the content source. |
height |
Window height in pixels. Required for openType set to newWindow; leave empty otherwise. |
width |
Window width in pixels. Required for openType set to newWindow; leave empty otherwise. |
position |
New-window display position: fullScreen, none, or topLeft. Specify only for newWindow. |
requireRowSelection |
For massActionButton, determines whether users must select individual rows before executing the action. Leave empty for other display types. |
protected |
Required packaging restriction. When true, components or subcomponents created in the installing organization cannot link to or reference this WebLink. |
masterLabel |
The untranslated master display label. It is not the component's deployment identifier. |
Behavior and Constraints
Content source and executable content
linkType determines which content-bearing element applies. Populate url for URL or JavaScript content, page for a Visualforce page, or scontrol for an s-control. Leave the other content-bearing elements empty.
Despite its name, url can contain executable JavaScript. An inspection that checks only page and scontrol references will miss that code. Both URL and JavaScript content must be escaped consistently with XML parsing rules. For example, a literal ampersand in the content is written as & in XML.
encodingKey selects the character encoding for URL content; it does not replace XML escaping. The default is UTF-8. Other exposed encodings include ISO-8859-1, Shift_JIS, ISO-2022-JP, EUC-JP, x-SJIS_0213, ks_c_5601-1987, Big5, GB2312, and Big5-HKSCS.
The presence of flow in the linkType enumeration does not establish a supported Flow-launching configuration. That value is reserved for future use.
Window settings depend on the opening mode
When openType is newWindow, both height and width are required. The browser-control settings hasMenubar, hasScrollbars, hasToolbar, showsLocation, and showsStatus also apply only to this mode, as do isResizable and position.
For every other opening mode, leave those window-specific elements empty. Changing openType can therefore make previously applicable window settings invalid for the new configuration.
Related-list selection and package protection
requireRowSelection applies only when displayType is massActionButton. Its selection requirement is separate from the button's content source.
protected establishes a packaging boundary, not end-user permissions. Setting it to true restricts references from components or subcomponents created in the installing organization; it does not declare who can access the target page or other content.
Deployment and Retrieval
Use the object-qualified fullName to select an individual WebLink. For example, in package.xml, use WebLink as the type and Contact.Send_SMS as the member. Inside the containing CustomObject definition, that child's fullName is Send_SMS.
WebLink does not support the wildcard character * in package.xml. List the required object-qualified members explicitly.
In Metadata API format, the definition is carried within the object's XML, such as objects/Contact.object, even when the manifest selects an individual WebLink. Salesforce DX source format separates WebLink source under the object's webLinks directory. This storage relationship does not require using the entire object as the deployment or deletion target.
For an unqualified local name, start with a letter, use only letters, digits, and underscores, and do not end with an underscore or use consecutive underscores. Do not substitute masterLabel for fullName; the label and deployment identity serve different purposes.
Keep target content and placement dependencies separate when diagnosing deployment failures. A layout's button reference is not the WebLink definition, and a WebLink's page reference is not the Visualforce page definition. Inspect the actual reference values to identify which component is missing or still in use.
An individual button can be targeted for deletion with the object-qualified identity, for example:
sf project delete source -m WebLink:MyObject__c.MyButton
A remaining layout reference can block deletion. Remove that reference before retrying in the reported dependency scenario; deleting the containing object is not required. See the CLI deletion command reference.
Relationships
CustomObject contains the WebLink definition, while separate interface configuration determines where it appears. Dependency analysis can span several components: a Visualforce page change can affect WebLinks targeting that page, which can in turn affect layouts or other consumers. These are possible connections; only actual consumer reference values establish placement. Link translations are separate from both content targets and placement.
References
Referenced By
-
CustomObject:listViewButtons,searchResultsCustomButtonsin search-layout configuration. -
CustomObjectTranslation:namein link translation entries. -
FlexiPage:actionNamein action configuration. -
HomePageComponent:links. -
Layout:customButtons,customLink,actionNamein button, link, and action structures. -
RecordActionDeployment:action.
Reported Issues
- A layout reference blocked deletion of a single button. In November 2025, a CLI deletion attempt was reported to fail because a page layout still referenced the WebLink. The answer identified individual WebLink deletion and removal of remaining consumer references, rather than deletion of the containing object. Single-button deletion report.
-
A source pull unexpectedly reduced the parent object's XML. In a 2020 scratch-org report, changing a custom button URL and pulling source returned the correct WebLink file, but replaced the parent object's broader XML content with a definition containing only
enableEnhancedLookup. The discussion did not establish a confirmed repair for that overwrite. Parent-object pull report. -
A deployment intended for WebLinks included additional object components. A 2020 report described fields, and possibly other object children, being included during a manifest-based deployment. An answer suggested deploying the specific
webLinkssource directory instead. This was a reported CLI scenario, not a general rule that WebLink deployment always deploys the whole object; wildcard selection remains unsupported for this type. Unexpected deployment scope report. -
A change set failed on an unresolved layout button reference. In 2018, an upload reported
customButtons - no WebLink named Surgery__c.Filter_Fields found. The reporter had previously deleted an associated Visualforce page but could not locate the remaining reference. No verified resolution was reported, so the discussion does not establish that deleting the page caused the failure. Missing layout-button dependency report. -
An Activity search-layout reference did not supply the button definition. In a 2016 deployment report, the submitted
Activityobject XML contained alistViewButtonsreference but the deployment could not find the WebLink. The answer proposed explicitly selectingActivity.update_activityas aWebLinkmember. It did not establish that a Task button can be reassigned to Activity merely by changing the manifest. Activity button deployment report.
Common Questions
How do I retrieve one custom button with package.xml?
Select type WebLink and an explicit object-qualified member, such as Contact.Send_SMS. Do not use *. In Metadata API format, the definition is returned within the object's XML.
Can I delete a WebLink without deleting its object?
Yes. Target the individual object-qualified identity, such as MyObject__c.MyButton. A remaining layout reference can block deletion and must be removed in that dependency scenario.
Why does a WebLink url element contain JavaScript?
When linkType is javascript, url stores JavaScript code rather than a navigation address. The content still must follow XML escaping rules.
Why is my deployed custom button not on the page layout?
The WebLink definition and its placement are separate. Check the actual consumer configuration, such as the layout's customButtons, customLink, or actionName references. The button's existence alone does not establish placement.
Can I use linkType flow to launch a Flow?
flow is reserved for future use. Its presence in the enumeration does not establish a supported Flow-launching configuration.