none
InfoPath data in SharePoint 2013 Forms library

    Question

  • Hello Folks,

    I have a requirement with my client to get the data stored within the InfoPath forms. I am able to open the forms as XML and get the data using SSOM. But, this is not acceptable by the Client. Can anyone suggest me in getting the data without having to publish the fields in InfoPath form.

    Thanks in Advance.

    Regards,

    Nagendra YR


    Thanks & Regards

    Tuesday, March 14, 2017 4:40 AM

Answers

  • Hi Nagendara,

    If you don't have the privilege of using SSOM code, we can also use .NET Client side object model to get the document from the document library.

    using (ClientContext clientcontext= new ClientContext("http://your server"))
    {
    
        //Load Libraries from SharePoint
        clientcontext.Load(clientcontext.Web.Lists);
        clientcontext.ExecuteQuery();
        foreach (List list in clientcontext.Web.Lists)
        {
           try
           {
                if (list.BaseType.ToString() == "DocumentLibrary")
                 {
                     // here u get all document library
                 }
           }
           catch()
           {}
        }
    }

    More information:

    Complete basic operations using SharePoint 2013 client library code

    http://sharepoint.stackexchange.com/questions/44303/how-to-get-only-the-document-libraries-from-a-sharepoint-site-using-sharepoint-c

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    • Marked as answer by Nagendra YR Wednesday, March 22, 2017 1:04 PM
    Tuesday, March 21, 2017 10:07 AM
    Moderator

All replies

  • Hi Nagendra,

    If you want to get the data from the InfoPath, we have to load the file as XML and read the data in the XML.

    To get the files in document library, we need use SharePoint API to achieve it.

    The following code snippet for your reference:

    using (SPSite site = new SPSite("http://<SharePoint_Site_URL>")) 
    { 
    	using (SPWeb web = site.OpenWeb()) 
    	{ 
    		//Get handle for forms library 
    		SPList formsLib = web.Lists["FormsLib"]; 
    
    		if (formsLib != null) 
    		{ 
    			foreach (SPListItem item in formsLib.Items) 
    			{ 
    				XmlDocument xml = new XmlDocument(); 
    
    				//Open XML file and load it into XML document 
    				using (Stream s = item.File.OpenBinaryStream()) 
    				{ 
    					xml.Load(s); 
    				} 
    
    				//read the data from the xml
    								
    			} 
    		} 
    	} 
    } 

    More information:

    Get data from InfoPath form using Object Model(C#)

    http://ravirapolu.blogspot.com/2012/10/get-data-from-infopath-form-using.html

    Programmatically retrieve an InfoPath form from a SharePoint library

    https://sites.google.com/site/sharebyme/sharepoint/infopath-service/programmatically-retrieve-an-infopath-form-from-a-sharepoint-library

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com


    Wednesday, March 15, 2017 7:53 AM
    Moderator
  • Hello Dennis,

    Thank you very much for your response. i did try this approach, but the catch here is I don't have the privilege of using SSOM code. 

    Hence looking for options to get the data from without having to promote the fields to Forms Library. Can we get the data from database?

    Any thoughts?

    Regards,

    Nagendra YR


    Thanks & Regards

    Tuesday, March 21, 2017 4:26 AM
  • Hi Nagendara,

    If you don't have the privilege of using SSOM code, we can also use .NET Client side object model to get the document from the document library.

    using (ClientContext clientcontext= new ClientContext("http://your server"))
    {
    
        //Load Libraries from SharePoint
        clientcontext.Load(clientcontext.Web.Lists);
        clientcontext.ExecuteQuery();
        foreach (List list in clientcontext.Web.Lists)
        {
           try
           {
                if (list.BaseType.ToString() == "DocumentLibrary")
                 {
                     // here u get all document library
                 }
           }
           catch()
           {}
        }
    }

    More information:

    Complete basic operations using SharePoint 2013 client library code

    http://sharepoint.stackexchange.com/questions/44303/how-to-get-only-the-document-libraries-from-a-sharepoint-site-using-sharepoint-c

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    • Marked as answer by Nagendra YR Wednesday, March 22, 2017 1:04 PM
    Tuesday, March 21, 2017 10:07 AM
    Moderator