Hello everybody,
I am working on Discussion Board list using Web Service. I am so supprised that the DB list is not the same as another list in SharePoint. The first sign of my mind is Calendar List Item, SharePoint stores the StartDate & EndDate with a different ways. To get the correctly data, we must understand clearly about architecture of Calendar list.
For now, the problem about Calendar was solved and faced to another problem. Discussion Board list has 2 item types: Dicussion (threads) and Message (replies). When you get all items by normaly, you only get the discussion items, take a look at code:
XmlDocument document = new XmlDocument();
XmlNode query = document.CreateNode(XmlNodeType.Element, "Query", "");
XmlNode viewFields = document.CreateNode(XmlNodeType.Element, "ViewFields", "");
XmlNode queryOptions = document.CreateNode(XmlNodeType.Element, "QueryOptions", "");
queryOptions.InnerXml = "<ViewAttributes Scope='RecursiveAll'/>";
Lists lists = new Lists(URL_SERVER);
lists.Credentials = CredentialCache.DefaultCredentials;
XmlNode node4 = lists.GetListItems(sourceList, "", query, viewFields, "", queryOptions);
Okey, even thought Scope attribute is set to "RecursiveAll", and SharePoint 2007 works fine. All items including reply items are list. But it does not work in SharePoint 2010, so it is not actually difficult to fix for SharePoint 2010. Just update your query CALM like the code below:
query.InnerXml = @"<Query>
<Where>
<Geq>
<FieldRef Name=""DiscussionLastUpdated"" />
<Value Type=""DateTime"">1900-01-01T00:00:00Z</Value>
</Geq>
</Where>
</Query>";
Yes, that's it.
2 comments:
Thanks, It works perfect. You saved lots of hours for me. :D
In order for this to really work correctly, remove the from the InnerXml.
Post a Comment