CustomPageWebLink defines a custom link in a home page component. It controls the link's content source, appearance, availability, and window behavior. It is distinct from WebLink, which represents other custom links stored within CustomObject.
A home page link can navigate to a URL or execute JavaScript. Its label and hyperlink appearance do not tell you which it does; inspect linkType and the corresponding content element.
Key Elements
| Element | What the Element Controls |
|---|---|
fullName |
The unique API identifier, inherited from Metadata. It must begin with a letter, contain only alphanumeric characters and underscores, and have neither a trailing underscore nor consecutive underscores. |
masterLabel |
The display label, separate from the API identifier. |
linkType |
Required. Selects the content source: url, javascript, page, or sControl. The enumerated value flow is reserved for future use. |
url |
The destination when linkType=url, or JavaScript content when linkType=javascript. Leave empty for other content types. Content must follow XML escaping rules. |
page |
The Visualforce page reference when linkType=page. Leave empty otherwise. |
scontrol |
The s-control name when linkType=sControl. Leave empty otherwise. |
displayType |
Rendering: link for a hyperlink, button for a button, or massActionButton for a button attached to a related list. |
openType |
Required. The window style used when clicked. Allowed values are newWindow, sidebar, noSidebar, replace, and onClickJavaScript. |
height, width
|
Window dimensions in pixels. Both are required for openType=newWindow; leave both empty otherwise. |
position |
New-window positioning: fullScreen, none, or topLeft. Leave empty unless openType=newWindow. |
encodingKey |
Required. Character encoding for URL content. The documented default is UTF-8; character encoding does not replace XML escaping. |
protected |
Required. When true, components created in the installing organization cannot link to or reference this component. |
availability |
Required. online means online-only availability; offline also includes offline use. |
requireRowSelection |
Described as requiring individual row selection for an action, but its documented condition uses an invalid openType value. See Documentation Inconsistencies. |
Behavior and Constraints
linkType, displayType, and openType control different things: content source, rendering, and invocation window style. Do not infer the content source from whether the component appears as a link or button.
Populate only the content element appropriate to linkType:
-
url: put the navigation destination inurl. -
javascript: put JavaScript inurl, not a navigation address. -
page: usepageto reference anApexPage, the metadata type for a Visualforce page. -
sControl: usescontrolto reference anScontrol.
Leave the other content elements empty. Although flow appears in the enumeration, it is reserved for future use and does not establish a supported Flow content configuration.
For openType=newWindow, provide both height and width. The window controls hasMenubar, hasScrollbars, hasToolbar, isResizable, showsLocation, and showsStatus apply only to this window style. Leave these controls, position, and both dimensions empty for other openType values.
protected restricts references from components created in an installing organization. It is a packaging restriction, not a user-permission setting.
Deployment and Retrieval
In file-based Metadata API format, each custom link definition has its own file in the package's weblinks folder, with the suffix .weblink. Use CustomPageWebLink as the type name in package.xml. The type supports * as a manifest wildcard.
Use the API identifier fullName, not the display label masterLabel, to identify the component. The identifier must be unique and follow the naming rules in the table.
Check content and window settings together when preparing a definition: unrelated content elements must be empty, and newWindow requires both dimensions. XML-escape the content of url whether it contains a URL or JavaScript. Changing encodingKey does not make unescaped XML valid.
Dependency inspection must include the selected content source. The structured page and scontrol references do not capture references embedded in JavaScript within url. JavaScript content can contain resource paths or Visualforce endpoints even when both structured target elements are empty.
Relationships
A home page component can reference a CustomPageWebLink, which can in turn reference a Visualforce page or s-control. This creates an indirect dependency through the link. The selected linkType and populated target determine which outgoing relationship applies; these possible relationships do not prove actual placement or usage.
References
Referenced By
-
CustomTab:splashPageLink. -
HomePageComponent:links. -
Translations:namein the relevant link translation entries.
Documentation Inconsistencies
The documented condition for requireRowSelection says it applies when openType=massAction. However, massAction is not an allowed openType value. massActionButton is a displayType value, not an openType value. The condition therefore does not establish a valid configuration for this type.
The official XML sample is not deploy-ready as printed: its closing encodingKey tag is malformed, and it omits width despite using openType=newWindow. Repair the tag and supply both required dimensions rather than copying the sample unchanged.
Reported Issues
-
A missing local definition did not resolve a reported package security-review finding. In July 2023, a first-generation managed-package author reported a "JS in Salesforce DOM" finding against a
CustomPageWebLinkthat they could not locate in their local project, even after attempting retrieval. The reported definition usedlinkType=javascriptandopenType=onClickJavaScript. ItsurlcontainedREQUIRESCRIPTexpressions referencing static resources and a Visualforce endpoint; the author said the referenced static resource files were empty. The response suggested inspecting Classic home page components in the org, particularly the packaging org. The discussion did not confirm that origin or a successful remediation. This report also shows why checking onlypageandscontrolcan miss references embedded in JavaScript. Security-review discussion.
Common Questions
What is the difference between CustomPageWebLink and WebLink?
CustomPageWebLink defines a custom link in a home page component. Other custom links are represented by WebLink within CustomObject.
How do I retrieve CustomPageWebLink metadata?
Include CustomPageWebLink in package.xml, using the component's API identifier or the supported * wildcard. File-based Metadata API definitions use the weblinks folder and .weblink suffix.
Why does the url element contain JavaScript?
When linkType=javascript, url stores executable JavaScript rather than a destination address. The content still must follow XML escaping rules.
Are height and width required for a custom home page link?
Both are required when openType=newWindow. Leave them empty for every other openType, along with the new-window-only controls.
Does protected control which users can click the link?
No. protected=true prevents components created in the installing organization from linking to or referencing the component. It is not a user-permission setting.