Search code examples
sharepointwindows-sharepoint-services

Sharepoint 2007: Insert a list item with hyperlink field via web services


I need to know how to insert a list item with a hyperlink field using the oob web services.

I already have the code to do the insert, just not sure about the hyperlink.

Here is a standard text field (just part of the code):

+ @"<Field Name=""Annotation"">" + this.messageEnvelope.DM.Annotation + "</Field>"

Now how can I insert a hyperlink , there is absolutely no documentation on this. Thanks in advance


Solution

  • SharePoint stores its links in this format (note the comma and space between the URL and the description):

    url, description
    http://example.com, An Example

    I'm not sure about the web service, but it should work just the same.

    From code, you can use the SPFieldUrlValue class to format this value:

    SPFieldUrlValue urlVal = new SPFieldUrlValue();
    urlVal.Url = "http://example.com";
    urlVal.Description = "An Example";
    string spUrlFormat = urlVal.ToString();