How to programmatically Submit in InfoPath 2010

July 11, 2011


Hi all. My store about how I can programmatically submit InfoPath forms in the SharePoint folder in library. So first you can get event Submit.

How I can do.

image

Second I create small code with class FileSubmitConnection.

The FileSubmitConnection class represents a data connection created in InfoPath using the Data Connection Wizard that specifies all the information necessary for submitting data to a Microsoft Windows SharePoint Services document library or other server that supports DAV connections.

The FileSubmitConnection object is accessible using the DataConnections property of the XmlForm class to return the connection from the DataConnectionCollection of the form template.

The FileSubmitConnection class provides the Filename property, which returns an XPathTypedValue object that evaluates to the file name that the current form will be given when the form is submitted by the FileSubmitConnection object. It also provides the FolderUrl property, which gets or sets the Uniform Resource Locator (URL) of folder to which the form will be submitted.

In addition to the default Execute method inherited from the DataConnection base class that performs a query operation using the values that were declaratively defined in InfoPath form template design mode, the FileSubmitConnection class also provides the FileSubmitConnection.Execute method, which allows you to specify a different source of data to submit.

My sample,

public void FormEvents_Submit(object sender, SubmitEventArgs e)
        {
            XPathNavigator root = MainDataSource.CreateNavigator();
            string url = root.SelectSingleNode("/my:моиПоля/my:GSKGroup/my:urlsite", NamespaceManager).Value;
            string directorat = root.SelectSingleNode("/my:моиПоля/my:Directorat", NamespaceManager).Value;
            string division = root.SelectSingleNode("/my:моиПоля/my:Division",

NamespaceManager).Value;
            SPSite oSiteCollection = new SPSite(url);
            SPWeb rootweb = oSiteCollection.RootWeb;
           

// Submit the form to SharePoint
            FileSubmitConnection fc = (FileSubmitConnection)this.DataConnections

["SharePoint Library Submit"];
            fc.FolderUrl = rootweb.Url + "/DocLib/" + directorat + "/" +

division.Replace("\"", " ");

            // Execute the submit connection
            try
            {
                fc.Execute();
                e.CancelableArgs.Cancel = false;
            }
            catch
            {
                e.CancelableArgs.Cancel = true;
            }

        }

Advertisements

2 Responses to “How to programmatically Submit in InfoPath 2010”

  1. Johna446 Says:

    Thanks so much for sharing all with the awesome info! I am looking forward to checking out far more posts! dddcafkfkead

  2. Johnk229 Says:

    I think this is a real great blog post.Much thanks again. fcdddcedkdge


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: