Newer Version Available

This content describes an older version of this product. View Latest

Weblink

Represents a Weblink defined in a custom object. This type extends the Metadata metadata type and inherits its fullName field.

Version

Weblinks are available in API version 12.0 and later.

Fields

The Weblink definition contains the following fields.

Field Name Field Type Description
availability WebLinkAvailability (enumeration of type string) Required. Indicates whether the Weblink is only available online (online, or if it is also available offline (offline).
description string A description of the Weblink.
displayType WebLinkDisplayType (enumeration of type string) Represents how this Weblink is rendered.

Valid values:

  • link for a hyperlink
  • button for a button
  • massAction for a button attached to a related list
encodingKey Encoding (enumeration of type string) Required. The default encoding setting is Unicode: UTF-8. Change the default encoding setting if the target of a link requires data in a different format. This is available if your Content Source is URL.

Valid values include:

  • UTF-8: “Unicode (UTF-8)” in the UI
  • ISO-8859-1: “General US & Western Europe (ISO-8859–1, ISO-LATIN-1)” in the UI
  • Shift_JIS: “Japanese (Shift-JIS)” in the UI
  • ISO-2022-JP: “Japanese (JIS)” in the UI
  • EUC-JP: “Japanese (EUC)” in the UI
  • ks_c_5601-1987: “Korean (ks_c_5601–1987)” in the UI
  • Big5: “Traditional Chinese (Big5)” in the UI
  • GB2312: “Simplified Chinese (GB2312)” in the UI
  • BIG5-HKSCS: “Traditional Chinese Hong Kong (Big5–HKSCS)” in the UI
  • x-SJIS_0213: “Japanese (Shift-JIS_2004)” in the UI
fullName string The name of the weblink with white spaces and special characters escaped for validity. The name can only contain characters, letters, and the underscore (_) character, must start with a letter, and cannot end with an underscore or contain two consecutive underscore characters.

Inherited from the Metadata component, this field is not 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 boolean If the openType is newWindow, whether to show the browser menu bar for the window (true or not (false). Otherwise this field should not be specified.
hasScrollbars boolean If the openType is newWindow, whether to show the scroll bars for the window (true) or not (false). Otherwise this field should not be specified.
hasToolbar boolean If the openType is newWindow, whether to show the browser toolbar for the window (true) or not (false). Otherwise this field should not be specified.
height int Height in pixels of the window opened by this Weblink. Required if the openType is newWindow, otherwise should not be specified
isResizable boolean If the openType is newWindow, whether to allow resizing of the window (true) or not (false). Otherwise this field should not be specified.
linkType WebLinkType (enumeration of type string) Required. Represents whether the content of this Weblink is specified by a URL, an sControl, a JavaScript code block, or a Visualforce page.
Valid values:
  • url
  • sControl
  • javascript
  • page
  • flow—Reserved for future use.
masterLabel string The master label for the Weblink.
openType WebLinkWindowType (enumeration of type string) Required. When this button is clicked, specifies the window style that will be used to display the content.

Valid values:

  • newWindow
  • sidebar
  • noSidebar
  • replace
  • onClickJavaScript
page string If the value of linkType is page, this field represents the Visualforce page; otherwise, this field should not be specified.
position WebLinkPosition (enumeration of type string) If the openType is newWindow, how the new window should be displayed. Otherwise this field should not be specified.

Valid values:

  • fullScreen
  • none
  • topLeft
protected boolean Required. Indicates whether this sub-component is protected (true) or not (false). Protected sub-components cannot be linked to or referenced by components or sub-components created in the installing organization.
requireRowSelection boolean If the openType is massAction, whether to require individual row selection to execute the action for this button (true) or not (false). Otherwise this field should not be specified.
scontrol string If the value of linkType is sControl, this field represents the name of the sControl; otherwise, this field should not be specified.
showsLocation boolean If the openType is newWindow, whether or not to show the browser location bar for the window; otherwise this field should not be specified.
showsStatus boolean If the openType is newWindow, whether or not to show the browser status bar for the window. Otherwise, this field should not be specified.
url string

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 neither of these, the this field should not be specified.

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

width int Width in pixels of the window opened by this Weblink.

Required if the openType is newWindow, otherwise should not be specified.

Java Sample

The following Java sample shows sample values for Weblink fields:

1swfobject.registerObject("clippy.codeblock-0", "9");public 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}

Declarative Metadata Sample Definition

The following is the definition of a Weblink in a custom object. For related samples, see HomePageComponent and HomePageLayout.

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>