Newer Version Available
WebLink
This type extends the Metadata metadata type and inherits its fullName field.
Version
WebLinks are available in API version 12.0 and later.
Fields
| Field Name | Field Type | Description |
|---|---|---|
| availability | WebLinkAvailability (enumeration of type string) | Required. Indicates whether the button or link is only available online (online, or if it is also available offline (offline). |
| description | string | A description of the button or link. |
| displayType | WebLinkDisplayType (enumeration of type string) |
Represents how the button or link is rendered.
Valid values are:
|
| encodingKey | Encoding |
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 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 | boolean | 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 | boolean | 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 | boolean | 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 | int | 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 | boolean | 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 | WebLinkType (enumeration of type string) |
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.
|
| 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 the button or link 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, leave this field empty. |
| position | WebLinkPosition (enumeration of type string) | If the value of OpenType is
newWindow, this field indicates how the
new window should be displayed. Otherwise, don’t specify a value. Valid values
are:
|
| protected | boolean | 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 | boolean | 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 | string | If the value of linkType is sControl, this field represents the name of the sControl. Otherwise, leave this field empty. |
| showsLocation | boolean | 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 | boolean | If the openType is newWindow, this field indicates whether to show the browser status bar for the window. Otherwise, leave this field empty. |
| 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 is neither of these options, leave this field empty. Content must be escaped in a manner consistent with XML parsing rules. |
| width | int | Width in pixels of the window opened by the button or
link. Required if the openType is newWindow. Otherwise, leave this field empty. |
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 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>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.