InfoPath 2007 CAML insert SharePoint error - InfoPath Dev
in

InfoPath Dev

InfoPath 2007 CAML insert SharePoint error

Last post 11-05-2013 01:54 PM by LWANG. 8 replies.
Page 1 of 1 (9 items)
Sort Posts: Previous Next
  • 04-19-2013 07:50 AM

    InfoPath 2007 CAML insert SharePoint error

    I am programming an InfoPath form which interacts with SharePoint to submit data to a list.  The form controls are all written in C# and using XML and CAML to submit data to the site.

     

    The form is working accurately about 95% of the time.  The other 5% nothing gets updated to the form.

     

    I am fairly certain the issue is happening when my CAML file is called.

     DataConnections["CustomListItemsSubmit"].Execute(); The CAML is created by this.         //AddMethodNode updates the xml file and uses it to append data to SharePoint List        private void AddMethodNode()        {            DateTimeOfEntry = Convert.ToString(DateTime.Now);                        //declare text file to store CAML file            System.Text.StringBuilder sb = new System.Text.StringBuilder();            //add passed arguments to CAML file            sb.AppendFormat("<Method ID=\"1\" Cmd=\"Update\">");            sb.AppendFormat("<Field Name=\"ID\">{0}</Field>", ID);            sb.AppendFormat("<Field Name=\"DisputeReviewAcknowledgement\">{0}</Field>", DateTimeOfEntry);            sb.AppendFormat("<Field Name=\"DisputeReviewResponse\">{0}</Field>", DisputeYesNo);            sb.AppendFormat("<Field Name=\"DisputeReviewComments\">{0}</Field>", DisputeComment);            sb.AppendFormat("<Field Name=\"DisputeReviewAttachment\">{0}</Field>", AttachmentLink);            sb.AppendFormat("</Method>");             //create XML document and add the CAML data to it            XmlDocument methodXML = new XmlDocument();            methodXML.LoadXml(sb.ToString());            //set reference to data source            XPathNavigator secDSNav = DataSources["CustomListCAML"].CreateNavigator();            XPathNavigator batchNav = secDSNav.SelectSingleNode("/Batch", NamespaceManager);            //append the XML date to the data source            batchNav.AppendChild(methodXML.DocumentElement.CreateNavigator());        }//end of AddMethodNode 

    all variables are strings and all fields in the SharePoint except DisputeReviewAttachment are single line text fields char limit 255.  The attachment field is a hyper link field that stores a link to a file uploaded to the sharepoint site.(the attachment will not allways have data)

     

     What is giving me the headache is that I cant find any trends in submissions that will not go through, it seems like on the ones that do not submit, they will not submit reguardless of what is supplied. Thank you for any insight or suggestions you can give.

     

  • 04-19-2013 07:54 AM In reply to

    Re: InfoPath 2007 CAML insert SharePoint error

    so the forum dosnt like how I am entering my code, is there a recomended way for me to do that?

  • 04-19-2013 08:14 AM In reply to

    Re: InfoPath 2007 CAML insert SharePoint error

    I struggle with getting my code to paste nicely in here as well - If I paste into Word, then into a Rich Text box in InfoPath, then into the forum, I succeed. I rarely bother with all that tho. :-)

    So - when you submit, you can pass in some additional XPath Navigators to get some error info back, and submit passing those in - submitDataconnection.Excute(null, outputNav, errorNav) - then get error info back from those.... http://msdn.microsoft.com/en-us/library/office/aa943097.aspx for more - passing in null for the inputNav means the data connection will use whatever you set up when you initially set up the submit connection. You can check the errorNav with something like XPathNavigator errorNode = errorNav.SelectSingleNode("//*[local-name() = 'errorstring']"). The outputNav may also have errors in it - check for ErrorCode or ErrorText.

     

    Hilary Stoupa

  • 04-19-2013 09:09 AM In reply to

    Re: InfoPath 2007 CAML insert SharePoint error

    thank you so much for the quick response.

    after reading the link you provided I think I am half understanding the recomendation, the idea is that I create a query connection to the fields I need to enter data to via an xml based web address connection. and using this rather than my CAML file i can submit the data and have a place to store the error message by creating an xpath to fields in my Main/myFields data source.

  • 04-19-2013 09:35 AM In reply to

    Re: InfoPath 2007 CAML insert SharePoint error

     Actually, I'm suggesting that you modify this:

    DataConnections["CustomListItemsSubmit"].Execute();  

    Create a web service connection instead and when you execute it you can pass in the output nav and errors nav to return any error info and track down the issue.

    Edited to add: Like this:

    WebServiceConnection shpSubmit = (WebServiceConnection) this.DataConnections["CustomListItemsSubmit"];

    Then shpSubmit.Execute(null, outputnav, errorsnav);

    Hilary Stoupa

  • 11-04-2013 08:12 AM In reply to

    • LWANG
    • Not Ranked
    • Joined on 10-29-2013
    • Posts 5

    Re: InfoPath 2007 CAML insert SharePoint error

     I was able to follow you up to shpSubmit.Execute(null, outputnav, errorsnav), but I am having trouble to retrieve the error text. Could you elaborate?

    Thanks!

     

     

  • 11-04-2013 02:22 PM In reply to

    Re: InfoPath 2007 CAML insert SharePoint error

     Here's sample code:
    http://msdn.microsoft.com/en-us/library/aa943097.aspx

    Skip the part where they create a nav for the input, and pass null instead.

    You'll find errors either in the errors nav or the output nav - run in debug to examine the results of those.

    Hilary Stoupa

  • 11-05-2013 10:15 AM In reply to

    • LWANG
    • Not Ranked
    • Joined on 10-29-2013
    • Posts 5

    Re: InfoPath 2007 CAML insert SharePoint error

     Yes, I see "0x81020054The user does not exist or is not unique." in outputNav.TypedValue and in Outputnav.OuterXml.Errortext, but I don't know how to access these fields.

    outputNav.SelectSingleNode("TypedValue", NamespaceManager).Value does not work, returns NullReferenceException.

    Any help you can give would be much appreciated!

     

  • 11-05-2013 01:54 PM In reply to

    • LWANG
    • Not Ranked
    • Joined on 10-29-2013
    • Posts 5

    Re: InfoPath 2007 CAML insert SharePoint error

     Never mind, I figured it out. I can just use outputNav.TypedValue.ToString()

    Thank you!

Page 1 of 1 (9 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.