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

Creating WebLinks from code using the Partner WSDL

I tried creating web links but they do not seem to show up, for example, under "Studio - Customize - Accounts - Web Links".  I'm using the following code to do it:

        Dim webLink As New sforce.sObject
        Dim webLinkArray(0) As sforce.sObject

        Dim webLinkXmlElement(5) As Xml.XmlElement
        Dim webLinkXmlDoc As New Xml.XmlDocument

        webLinkXmlElement(0) = webLinkXmlDoc.CreateElement("LinkType")
        webLinkXmlElement(0).InnerText = "URL"
        webLinkXmlElement(1) = webLinkXmlDoc.CreateElement("Name")
        webLinkXmlElement(1).InnerText = "WIL from code"
        webLinkXmlElement(2) = webLinkXmlDoc.CreateElement("OpenType")
        webLinkXmlElement(2).InnerText = "Sidebar"
        webLinkXmlElement(3) = webLinkXmlDoc.CreateElement("PageEnumOrId")
        webLinkXmlElement(3).InnerText = "AccountDetail"
        webLinkXmlElement(4) = webLinkXmlDoc.CreateElement("Url")
        webLinkXmlElement(4).InnerText = ""
        webLinkXmlElement(5) = webLinkXmlDoc.CreateElement("EncodingKey")
        webLinkXmlElement(5).InnerText = "Unicode (UTF-8)"

        webLink.type = "WebLink"
        webLink.Any = webLinkXmlElement

        webLinkArray(0) = webLink

        Dim sr() As sforce.SaveResult = binding.create(webLinkArray)

Am I missing a field that is required?  I just started using the Parter WSDL, so I am still a bit unfamiliar with it vs. the Enterprise WSDL.

Also, what are the valid values for EncodingKey?

Any help would be appreciated.  Thank you.



Hi jeselon,

You need to use the sforce Explorer.  I have attached a screenshot that gives you an example of how using this tool will help you do your development.

The problem with your code is that for every picklist field in the web link object, you've used an incorrect value.  The correct values are given in the describe call results and using the sforce explorer, it is easy to determine what the valid values are.

The encoding key values are also given in a picklist field.  For your code sample you should use "UTF-8", "url" instead of "URL", "sidebar" instead of "Sidebar" and "accountDetail" instead of "AccountDetail".

Every failed save result object has error messages as well as wether or not the call was successful.  To determine why something is not happening as you expect, the first place to start is to check to see if the call was successful and, if not, to check the error for that record.

sforce.SaveResult sr = binding.create(new sforce.sObject[]{wl})[0];

if (sr.success)

System.Windows.Forms.MessageBox.Show("Successfully created web link.");


System.Windows.Forms.MessageBox.Show("Error creating weblink: " + sr.errors[0].message);



Thanks for the response Dave.

Now I would like to learn more about the sforce Explorer.  I was unable to see the screen shot that you mentioned.  Also, where might I be able to get this tool?

Thank you.



You might want to do a search for sforce explorer ... for more info ... or you can get it directly from


Hi jeselon,

My bad.  Forgot to attach it.


Thanks for the help!
We created a WebLink for taskDetail on 11/17
I verified thru sforce Explorer
But where do I find this link ?
John SaundersJohn Saunders

Have you added the WebLink to a page layout yet? That's the only way to see it.