Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm using the sharepoint's web service (GetListItems) method to get some fields data for list's items, now in addition for the information that i retrieve for an item I need its direct URL, so i can give the user an optional link to click in order to navigate smoothly to that item in the sharepoint website

Here is my code that gets the item's data:

XmlNode ndQuery = xmlDoc.CreateNode(XmlNodeType.Element, "Query", "");
XmlNode ndViewFields =
    xmlDoc.CreateNode(XmlNodeType.Element, "ViewFields", "");
XmlNode ndQueryOptions =
    xmlDoc.CreateNode(XmlNodeType.Element, "QueryOptions", "");

var cc = new CredentialCache();
cc.Add(
      new Uri(url),
      "NTLM",
      new NetworkCredential(username, password, domain));
SPListWebService.Credentials = cc;
SPListWebService.Url = url + "/_vti_bin/Lists.asmx";


//Query Options Node
ndQueryOptions.InnerXml =
    "<IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns>" +
    "<DateInUtc>TRUE</DateInUtc>";
//Qyery node
foreach (DataRow row in view.Rows)
{
    string v = row[ffdmn].ToString();
    ndQuery.InnerXml = string.Format("<Where><Eq><FieldRef Name='{0}'/>" +
   "<Value Type='Text'>{1}</Value></Eq></Where>", sfdmname, v);

    XmlNode ndListItems =
        SPListWebService.GetListItems(listName, null, ndQuery,
        ndViewFields, null, ndQueryOptions, null);

    foreach (XmlNode node in ndListItems.ChildNodes)
    {
        if (node.Name == "rs:data")
            foreach (XmlNode innerNode in node.ChildNodes)
                if (innerNode.Name == "z:row")
                {
                   //I do some logic here to get the targeted fields
                }
    }
}

Any help?

(Also asked here)

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

You can get ows_EncodedAbsUrl (document libraries have a correct url, but lists do not):

http://server/sites/SiteCollection/SubSite/Lists/My%20List/4_.000

Then, do a little string manipulation to get a valid URL:

http://server/sites/SiteCollection/SubSite/Lists/My%20List/DispForm.aspx?ID=4
share|improve this answer
add comment

I suggest you build a new URL by string replacement on the existing path to the web service (which you know).

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.