Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Filtering Records in MOSS 2007 Custom List

Filtering Records in MOSS 2007 Custom List

Filtering Records in MOSS 2007 Custom List


I am using VB.Net in Visual Studio 2010 and using web services to connect to SharePoint 2007 to retrieve custom list data. I can retrieve all records from the SharePoint custom list but when I try to filter out records and fields using the CAML fragments in the query and viewFields objects listed below, it does not filter either. I have tried many different variations (using "ows_" field name and without) to get a different query result but with no luck. It gets very strange when I use the viewFields object, it filters out the data listed in the viewFields object but leaves all the unwanted fields (I think it should work the other way). No error messages are returned. Each and every time, the results set returns all the records and fields in the list up to the RowLimit property as if the query and viewFields objects were not considered in the query. I have attached the code below. Any assistance to help resolve my dilemma would be greatly appreciated.  


Private Function GetContractMainDataSet(ByVal cInConfiguratorName As String) As String
        clsFunctions.DisplayStatusMessage("Retrieving Records, please wait...", stMessage)
            Dim ds As New DataSet

            Dim cGUID_List As String = clsSP.cGUID_List_Configurator_Inventory_Log
            Dim cGUID_View As String = "{085BAED5-3F10-4885-A99F-E6A5FEB1881A}"

            Dim xmlDoc As XmlDocument = New XmlDocument
            Dim query As System.Xml.XmlElement = xmlDoc.CreateElement("Query")
            Dim viewFields As System.Xml.XmlElement = xmlDoc.CreateElement("ViewFields")
            Dim queryOptions As System.Xml.XmlElement = xmlDoc.CreateElement("QueryOptions")

            query.InnerXml = "<Query><OrderBy><FieldRef Name='Assigned Configurator' /></OrderBy>" & _
"<Where><Eq><FieldRef Name=""ows_Assigned Configurator"" />" & _
                    "<Value Type=""Text"">" & cInConfiguratorName & "</Value></Eq></Where></Query>"

            viewFields.InnerXml =  _
                "<FieldRef Name='Title' />" & "<FieldRef Name='ows_Column3' />" & _
                "<FieldRef Name='ows_Column4' />" & "<FieldRef Name='ows_Column5' />" & _
                "<FieldRef Name='ows_Config_User' />" & "<FieldRef Name='ows_Smoke_User' />" & _
                "<FieldRef Name='ows_Super_User' />" & "<FieldRef Name='ows_ID' />)")

            queryOptions.InnerXml = "<queryoptions><IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns>" & _

            Dim cRowLimit As String = "90"
            Dim cWebID As String = ""

            Dim objCredentials As New NetworkCredential(clsSP.cUSID, clsSP.cPWID, "CS")
            Dim SPList As New WS_WGK_List.Lists
            With SPList
                .Credentials = objCredentials
                .Url = clsSP.cURL_Contract_List

                'Get the list of configurator specific items...
                Dim nodeSP As XmlNode = .GetListItems(clsSP.cGUID_List_Configurator_Inventory_Log, _
                    cGUID_View, query, viewFields, cRowLimit, queryOptions, cWebID)
                If Not nodeSP Is Nothing And nodeSP.InnerXml.Length > 0 Then
                    Dim reader As XmlTextReader = New XmlTextReader(nodeSP.OuterXml, XmlNodeType.Element, Nothing)
                    '??? - Not sure what to do here...
                End If
            End With

            Dim nCnt As Integer = ds.Tables(1).Rows.Count
            If nCnt > 0 Then
                With dgvContracts
                    .DataSource = ds
                    .DataMember = ds.Tables(1).TableName
                End With

                clsFunctions.DisplayStatusMessage("Ready...", stMessage)
                clsFunctions.DisplayStatusMessage("No Status Records Found...", stMessage)
                tmrMain.Interval = 5000
                tmrMain.Enabled = True
            End If

            Return Nothing
        Catch ex1 As System.Web.Services.Protocols.SoapException
            MsgBox("ERROR #1: " & ex1.Message, MsgBoxStyle.Critical, "SharePoint Data Error")
        Catch ex2 As Exception
            MsgBox("ERROR #2: " & ex2.Message, MsgBoxStyle.Critical, "Data Retrieval Error")
        End Try
    End Function


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close