WebLink

Represents a custom button or link defined in a custom object.

Where possible, we changed noninclusive terms to align with our company value of Equality. We maintained certain terms to avoid any effect on customer implementations.

Important

Parent Type 

This type extends Metadata and inherits its fields.

Version 

WebLinks are available in API version 12.0 and later.

Fields 

availability 

  • Type: WebLinkAvailability (enumeration of type string)
  • Required: Yes
  • Description: Required. Indicates whether the button or link is only available online (online, or if it is also available offline (offline).

description 

  • Type: string
  • Required: No
  • Description: A description of the button or link.

displayType 

  • Type: WebLinkDisplayType (enumeration of type string)
  • Required: Yes
  • Description: Represents how the button or link is rendered.
  • Possible values:
    • link — for a hyperlink
    • button — for a button
    • massActionButton — for a button attached to a related list

encodingKey 

  • Type: Encoding (enumeration of type string)

  • Required: No

  • Description: Required. The default encoding setting is Unicode: UTF-8. Change it if your template requires data in a different format. This is available if your content source is URL.

    Valid values include:

  • Possible values:

    • UTF-8 — Unicode (UTF-8)
    • ISO-8859-1 — General US & Western Europe (ISO-8859–1, ISO-LATIN-1)
    • Shift_JIS — Japanese (Shift-JIS)
    • ISO-2022-JP — Japanese (JIS)
    • EUC-JP — Japanese (EUC-JP)
    • x-SJIS_0213 — Japanese (Shift-JIS_2004)
    • ks_c_5601-1987 — Korean (ks_c_5601-1987)
    • Big5 — Traditional Chinese (Big5)
    • GB2312 — Simplified Chinese (GB2312)
    • Big5-HKSCS — Traditional Chinese Hong Kong (Big5–HKSCS)

fullName 

  • Type: string

  • Required: No

  • Description: The name of the custom button or link with white spaces and special characters escaped for validity. The name can only contain characters, letters, and the underscore (_) character. The name must start with a letter, and can’t end with an underscore or contain two consecutive underscore characters.

    Inherited from the Metadata component, this field isn’t defined in the WSDL for this component. It must be specified when creating, updating, or deleting. See create() to see an example of this field specified for a call.

hasMenubar 

  • Type: boolean
  • Required: No
  • Description: If the openType is newWindow, this field indicates whether to show the browser menu bar for the window (true) or not (false). Otherwise, leave this field empty.

hasScrollbars 

  • Type: boolean
  • Required: No
  • Description: If the openType is newWindow, this field indicates whether to show the scroll bars for the window (true) or not (false). Otherwise, leave this field empty.

hasToolbar 

  • Type: boolean
  • Required: No
  • Description: If the openType is newWindow, this field indicates whether to show the browser toolbar for the window (true) or not (false). Otherwise, leave this field empty.

height 

  • Type: int
  • Required: No
  • Description: Height in pixels of the window opened by the custom button or link. Required if the openType is newWindow. Otherwise, leave this field empty.

isResizable 

  • Type: boolean
  • Required: No
  • Description: If the openType is newWindow, this field indicates whether to allow resizing of the window (true) or not (false). Otherwise, leave this field empty.

linkType 

  • Type: WebLinkType (enumeration of type string)
  • Required: Yes
  • Description: Required. Represents whether the content of the button or link is specified by a URL, an sControl, a JavaScript code block, or a Visualforce page.
  • Possible values:
    • url
    • sControl
    • javascript
    • page
    • flow — Reserved for future use.

masterLabel 

  • Type: string
  • Required: No
  • Description: Master label for this object. This display value is the internal label that is not translated.

openType 

  • Type: WebLinkWindowType (enumeration of type string)
  • Required: Yes
  • Description: Required. When the button or link is clicked, specifies the window style that will be used to display the content.
  • Possible values:
    • newWindow
    • sidebar
    • noSidebar
    • replace
    • onClickJavaScript

page 

  • Type: string
  • Required: No
  • Description: If the value of linkType is page, this field represents the Visualforce page. Otherwise, leave this field empty.

position 

  • Type: WebLinkPosition (enumeration of type string)
  • Required: No
  • Description: If the value of OpenType is newWindow, this field indicates how the new window should be displayed. Otherwise, don’t specify a value.
  • Possible values:
    • fullScreen
    • none
    • topLeft

protected 

  • Type: boolean
  • Required: Yes
  • Description: Required. Indicates whether this subcomponent is protected (true) or not (false). Protected subcomponents can’t be linked to or referenced by components or subcomponents created in the installing organization.

requireRowSelection 

  • Type: boolean
  • Required: No
  • Description: If the displayType is massActionButton, this field indicates whether to require individual row selection to execute the action for this button (true) or not (false). Otherwise, leave this field empty.

scontrol 

  • Type: string
  • Required: No
  • Description: If the value of linkType is sControl, this field represents the name of the sControl. Otherwise, leave this field empty.

showsLocation 

  • Type: boolean
  • Required: No
  • Description: If the openType is newWindow, this field indicates whether to show the browser location bar for the window (true) or not (false). Otherwise, leave this field empty.

showsStatus 

  • Type: boolean
  • Required: No
  • Description: If the openType is newWindow, this field indicates whether to show the browser status bar for the window. Otherwise, leave this field empty.

url 

  • Type: string

  • Required: No

  • Description: If the value of linkType is url, this is the URL value. If the value of linkType is javascript, this is the JavaScript content. If the value is neither of these options, leave this field empty.

    Content must be escaped in a manner consistent with XML parsing rules.

width 

  • Type: int

  • Required: No

  • Description: Width in pixels of the window opened by the button or link.

    Required if the openType is newWindow. Otherwise, leave this field empty.

Declarative Metadata Sample Definition 

The following is the definition of a WebLink in a custom object. For related samples, see Declarative Metadata Sample Definition and Declarative Metadata Sample Definition.

1<?xml version="1.0" encoding="UTF-8"?>
2<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
3....
4    <WebLinks>
5        <fullName>googleButton</fullName>
6        <availability>online</availability>
7        <displayType>link</displayType>
8        <encodingKey>UTF-8</encodingKey>
9        <hasMenubar>false</hasMenubar>
10        <hasScrollbars>true</hasScrollbars>
11        <hasToolbar>false</hasToolbar>
12        <height>600</height>
13        <isResizable>true</isResizable>
14        <linkType>url</linkType>
15        <masterLabel>google</masterLabel>
16        <openType>newWindow</openType>
17        <position>none</position>
18        <protected>false</protected>
19        <showsLocation>false</showsLocation>
20        <showsStatus>false</showsStatus>
21        <url>http://www.google.com</url>
22        <width>600</width>
23    </WebLinks>
24....
25</CustomObject>

Java Sample 

The following Java sample shows sample values for WebLink fields:

1public void WebLinkSample(String name) throws Exception {
2 WebLink WebLink = new WebLink();
3 // name variable represents the full name of the object 
4 // on which to create the WebLink, for example, customObject__c
5 WebLink.setFullName(name + ".googleButton");
6 WebLink.setUrl("http://www.google.com");
7 WebLink.setAvailability(WebLinkAvailability.online);
8 WebLink.setLinkType(WebLinkType.url);
9 WebLink.setEncodingKey(Encoding.fromString("UTF-8"));
10 WebLink.setOpenType(WebLinkWindowType.newWindow);
11 WebLink.setHeight(600);
12 WebLink.setWidth(600);
13 WebLink.setShowsLocation(false);
14 WebLink.setHasScrollbars(true);
15 WebLink.setHasToolbar(false);
16 WebLink.setHasMenubar(false);
17 WebLink.setShowsStatus(false);
18 WebLink.setIsResizable(true);
19 WebLink.setPosition(WebLinkPosition.none);
20 WebLink.setMasterLabel("google");
21 WebLink.setDisplayType(WebLinkDisplayType.link);
22
23 AsyncResult[] asyncResults = metadataConnection.create(new WebLink[]{WebLink});
24 // After the create() call completes, we must poll the results of checkStatus() 
25 // 
26
27}

Wildcard Support in the Manifest File 

This metadata type doesn’t support the wildcard character * (asterisk) in the package.xml manifest file. For information about using the manifest file, see Deploying and Retrieving Metadata with the Zip File.