How to Enqueue Submits While Offline
Applies to: Microsoft Office InfoPath 2003 SP1
User fills out forms for a particular form template while the laptop is disconnected from the network. Upon reconnection, seamlessly syncrhonize the offline forms to a Windows SharePoint Services form library.
Using OnSubmitRequest, you can have the code save to the offline folder depending on if we're offline or not, as in the following code, which is written in C# using our Visual Studio .NET Toolkit. You will also need to add a project reference to System.Xml.dll and the using System.XML; directive to your form code.
public void OnSubmitRequest(DocReturnEvent e)
Then, if you've been offline for a while and a number of files have built up, you can run the following jscript to invoke InfoPath externally and force a submit looping through the files, as below:
I can't for the life of me get this to work with InfoPath 2010. Could anyone provide a tutorial or short walkthrough?
Thanks in advance.
The code for InfoPath 2007 or 2010 is significantly shorter:
public void FormEvents_Submit(object sender, SubmitEventArgs e)
if (Application.MachineOnlineState == MachineState.Online)
this.DataConnections["SharePoint Library Submit"].Execute(); //Assumes your submit connection is named as shown
string strSaveLoc = @"C:\Submit\Form_";
this.SaveAs(strSaveLoc + DateTime.Now.ToString("yyyy.MM.dd_HH.mm.ss.ff") + ".xml");
e.CancelableArgs.Cancel = false;
catch (Exception ex)
e.CancelableArgs.Cancel = true;
With the above code, if I am offline, the form "submits" (saves) to the local machine location I specified above. I can then open that form when I am back online and it will submit to my SharePoint library.
Hi can the same code be used in infopath 2007.
The only way this will work in InfoPath 2007 and later is if you change the code to be InfoPath 2003 Compatible. The object model changed with 2007 so if you want to use the later object model you will need to re-write this code using the new methods, properties, etc.