Submit Data to Sharepoint form library

A

Afzal

Is it possible to submit the partial data from an Infopath form to
sharepoint form library?

My scenario:

I have a form which contains a repeating section for storing some data
and when user click save/submit then I want to save the main form as
well as create a sub form in the sharepoint form library.

Any help is greatly appreciated.

Thanks,

Afzal
 
S

Shiva[autonomysystems.com]

Hi Afzal,

As of your requirement sub form of is set of nodes right. You need to get
the parent node of that group of nodes. After getting the node you need to
get the xml using below the code.

//Get the sub form node
IXMLDOMNode subformNode = thisXDocument.DOM.selectSingleNode("XPath of your
node");
//Get XML string node
string xmlStringNode = subformNode.xml;

Using below you can submit the form share point

//Save file using HTTPWebrequest
private bool SaveFileToSharepoint(string destinationURL, xmlStringNode)
{
byte[] bytes = System.Text.Encoding.UTF8.GetBytes(xmlString);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(destinationURL);
request.Method = "PUT";
request.Credentials = System.Net.CredentialCache.DefaultCredentials;
request.AllowWriteStreamBuffering = true;

Stream stream = request.GetRequestStream();
stream.Write(bytes, 0, bytes.Length);
stream.Flush();
stream.Close();

HttpWebResponse response = null;
try
{
response = (HttpWebResponse)request.GetResponse();
}
catch (WebException ex)
{
response = (HttpWebResponse)ex.Response;
}

if (response != null)
{
HttpStatusCode statusCode = response.StatusCode;
response.Close();

if(statusCode == HttpStatusCode.OK || statusCode == HttpStatusCode.Created)
{
return true;
}
else
{
return false;
}
}
return false;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top