function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ChunWuChunWu 

Retrieve Weblink metadata

In my current development org, I add a custom link on an object which is defined in a managed package. Now I am trying to persist the metadata and then migrate this custom link to another org. According to Force.com Migration Tool Guide, <Type> element with value 'Weblink' should be manually specified in package.xml. It also says, 'this type is retrieved or deployed as part of a custom object file. You must dot-qualify the object name before the component name.'. I put it like the following code in package.xml but it is not grabbing any custom link metadata in the custom object as is expected. Any comments would be highly appreciated.

 

<types>
    <members>[packagePrefix.customObject__c].[customLinkName]</members>
    <name>Weblink</name>
</types>

 

 

sfdcfoxsfdcfox

I can't seem to find a good example of using the method that you're suggesting; normally, Weblinks are controlled through the CustomObject XML, as the following example (from the documentation):

 

 

<?xml version="1.0" encoding="UTF-8"?>
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata">
....
    <webLinks>
        <fullName>detailPageButton</fullName>
        <availability>online</availability>
        <displayType>button</displayType>
        <hasScrollbars>true</hasScrollbars>
        <height>600</height>
        <isResizable>true</isResizable>
        <linkType>url</linkType>
        <masterLabel>detailPageButon</masterLabel>
        <openType>newWindow</openType>
        <position>none</position>
        <protected>false</protected>
        <url>http://google.com</url>
    </webLinks>
    ....
</CustomObject>

You deploy these custom links by deploying the relevant CustomObject:

 

 

 

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
        <members>Custom_Object__c</members>
        <name>CustomObject</name>
    </types>
    <version>20.0</version>
</Package>

While it does specify that you can use an object-name.component-name syntax, I can't find a single example where it's used. In each case, it appears to be included as part of the metadata for the CustomObject. You should note that unless you have a destructiveChanges.xml file, you won't delete unreferenced WebLink entries by accident (i.e. if you have 5 custom links, and reference only one in the .object file, the remaining four are not automatically deleted when deploying).

 

 

You should probably just retrieve the CustomObject as a whole and re-deploy it.

ChunWuChunWu

Hi sfdcfox, Thanks for your comment. This indeed retrieves the <weblinks> metadata of the object but it also grabs all the information for this Object which is in the managed package. All I need is to persist the <weblinks> metadata of this object. The concept would be very similar to the <CustomField> element which just grab metadata of the newly added fields rather than the whole custom object in the managed package.

Kirill_YunussovKirill_Yunussov
Instead of prefixing the managed packaged namespace with a dot, you will need to prefix it with a double-underscore:
<types>
    <members>[packagePrefix__customObject__c].[customLinkName]</members>
    <name>Weblink</name>
</types>
It will work then.  
You can also delete these custom links and buttons this way as well, by putting that snippet in destructiveChanges.xml
 
Frans Flippo 14Frans Flippo 14
Note that metadata types are case sensitive.

I tried various variations of this with sfdx force:source:retrieve (which I'm assuming works the same as the Force.com Migration Tool when it comes to naming metadata) and found that WebLink needs to be spelled with a capital W and a capital L.

Hope this helps,
Frans