Newer Version Available
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:
|
| encodingKey | Encoding (enumeration of type string) |
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:
|
| 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, this field 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.
|
| masterLabel | string | Master label for this object. This display value is the internal label that is not translated. |
| 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:
|
| 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:
|
| 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 to show the browser location bar for the window (true) or not (false); 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:
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}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>