WSS 3.0 with IF07 Caml query issue and dropdown list problem - InfoPath Dev
in

InfoPath Dev

WSS 3.0 with IF07 Caml query issue and dropdown list problem

Last post 05-02-2007 08:25 AM by Matt Faus. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 04-26-2007 09:16 AM

    • buzzby
    • Top 200 Contributor
    • Joined on 07-11-2005
    • United Kingdom
    • Posts 60

    WSS 3.0 with IF07 Caml query issue and dropdown list problem

    I am creating a form template using VSTO in visual studio 2005. Everything is FULL TRUST and the form template is being loaded in a forms document library in Sharepoint 3.0.

    I only want to use the form in browser only mode.

    I am quite new at this so please be patient. I am creating a simple support ticket system

     

    I am having a nightmare trying to query a custom sharepoint list. The query is returning data but the data is not filtered. here is the code i am using

     


    StringBuilder camlBuilder = new StringBuilder();
                string xpath;

                xpath = "/my:myFields/my:ClientName";
                XPathNavigator ClientName = this.MainDataSource.CreateNavigator().SelectSingleNode(xpath, NamespaceManager);

                xpath = "/my:myFields/my:test";
                XPathNavigator test = this.MainDataSource.CreateNavigator().SelectSingleNode(xpath, NamespaceManager);

                camlBuilder.Append("<Query>");
                camlBuilder.Append("<Where>");
                camlBuilder.Append("<Eq>");           
                camlBuilder.Append("<FieldRef Name=\"Company\" />");
                camlBuilder.Append("<Value Type=\"Text\">");
                    camlBuilder.Append(ClientName.Value.ToString()); 
                camlBuilder.Append("</Value>");           
                camlBuilder.Append("</Eq>");
                camlBuilder.Append("</Where>");
                camlBuilder.Append("</Query>");

                string queryText = camlBuilder.ToString();

                SPWeb site = SPContext.Current.Web;
               
                SPList list = site.Lists["Client Contact List"]; //name of list
                SPQuery query = new SPQuery(list.DefaultView);
               
                query.Query = queryText;

                xpath = "/my:myFields/my:debug";
                XPathNavigator debug = this.MainDataSource.CreateNavigator().SelectSingleNode(xpath, NamespaceManager);
               
                debug.SetValue("Query = " + query.Query);

                SPListItemCollection results = list.GetItems(query);
               

                xpath = "/my:myFields/my:ClientContact";
                XPathNavigator ClientContact = this.MainDataSource.CreateNavigator().SelectSingleNode(xpath, NamespaceManager);

                xpath = "/my:myFields/my:Issue";
                XPathNavigator Issue = this.MainDataSource.CreateNavigator().SelectSingleNode(xpath, NamespaceManager);
                Issue.SetValue(ClientContact.OuterXml.ToString());

                foreach (SPListItem l in results)
                {
                    try
                    {
                        ClientContact.SetValue(l["Full_x0020_Name"].ToString());
                        test.SetValue(test.Value.ToString() + " " + l["Full_x0020_Name"].ToString());
                    }
                    catch (Exception exp)
                    {
                        xpath = "/my:myFields/my:debug";
                    
                        debug.SetValue(exp.Message);
                    }
                }

     

     

    Other issue.

     

    I then want to take this returned query and load a drop down list with the information. I cannot find ANY code on the internet anyway that explains how to do this. I am trying to output the XPathNavigator to get the XML but it doesn't seem to work. Please any help is desperately required.

     

     

    Regards

     

     

    Paul 

  • 05-02-2007 08:25 AM In reply to

    Re: WSS 3.0 with IF07 Caml query issue and dropdown list problem

    Hi buzzby,

    For the problems with CAML I would suggest taking a look at these two links.  The SharePoint SDK has a great section on CAML and how to formulate everything.  The second link is a program that will construct the CAML query for you!

    http://www.microsoft.com/downloads/details.aspx?familyid=aa3e7fe5-daee-4d10-980f-789b827967b0&displaylang=en

    http://www.u2u.info/Blogs/Patrick/Lists/Posts/Post.aspx?ID=1315

    To fill the drop-down with the results of your query, you should make the drop-down populate from a 2DS and then manipulate that 2DS from within your code to get it to output what you want.

    http://www.infopathdev.com/blogs/greg/archive/2004/07/28/Populate-a-Drop_2D00_Down-List-Box-via-a-Secondary-Data-Source.aspx

     

    Matt Faus / Microsoft InfoPath MVP
    Qdabra® Software / Streamline data gathering to turn process into knowledge
Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.