Saturday, November 29, 2003

Programmatically Submit an InfoPath Form to a Sharepoint Team Services Document Library

Using the custom submit functionality of InfoPath it is possible to submit a form directly to a Windows Sharepoint Form Library using the following code.

 

function XDocument::OnSubmitRequest(eventObj)

{

    // If the submit operation is successful, set

    // eventObj.ReturnStatus = true

    var fSuccessful = false;

 

    // Set the URL of the file that you want to submit here.

    var strUrl = "http://ServerName/SiteName/DocumentLibraryName/testform.xml";

 

    try

    {

        // Create an xmlhttp object.

        var oXmlHttp = new ActiveXObject("MSXML2.XMLHTTP");

 

        // Check whether the document with the same name already exists on SharePoint Team Services (STS).

        oXmlHttp.Open("HEAD", strUrl, false);

        oXmlHttp.Send();

 

        //  No document with the URL has been found. Continue to submit.

        // If you must replace the original file, you must call

        // oXmlHttp.Open("DELETE", strUrl, false) to delete the document

        // on STS first.

        if (oXmlHttp.Status == 404)

        {

            // Put the document on STS.

            oXmlHttp.Open("PUT", strUrl, false);

            oXmlHttp.Send(XDocument.DOM.xml);

 

            //  A 200 status code or a 201 status code indicates that the form has been submitted successfully.

            if (oXmlHttp.Status == 200 || oXmlHttp.Status == 201)

            {

                fSuccessful = true;

            }

        }

    }

    catch (ex){}

   

    if (fSuccessful)

    {

        XDocument.UI.Alert("Document submitted successfully!");

        eventObj.ReturnStatus = true;

    }

    else

    {

        eventObj.ReturnStatus = false;

    }

}

 

For more information about this take a look at the following support article.

 

How To: Programmatically Submit an InfoPath Form to a SharePoint Team Services Document Library


10:09:50 PM    
comment [] trackback []

Retrieving RSS Data to a Windows Form

I am working on some interesting stuff with pulling and reading RSS data. One thing I wanted to get up fairly quickly is a little sample that can be used to retrieve and show RSS based data from a Windows Form DataGrid using five lines of code.

 

Dim reader As XmlTextReader = New XmlTextReader _("http://radio.weblogs.com/0131777/categories/datagridProgramming/rss.xml")

Dim ds As DataSet = New DataSet

ds.ReadXml(reader)

DataGrid1.DataSource = ds

 

Now that is cool!


6:18:03 PM    
comment [] trackback []