Hi
I have designed a form with Intopath and it is working well, however I cannot close the form on Submit. I have created some code as follows:
{
public partial class FormCode
{
// Member variables are not supported in browser-enabled forms.
// Instead, write and read these values from the FormState
// dictionary using code such as the following:
//
// private object _memberVariable
// {
// get
// {
// return FormState["_memberVariable"];
// }
// set
// {
// FormState["_memberVariable"] = value;
// }
// }
// NOTE: The following procedure is required by Microsoft Office InfoPath.
// It can be modified using Microsoft Office InfoPath.
public void InternalStartup()
{
EventManager.FormEvents.Submit += new SubmitEventHandler(FormEvents_Submit);
}
public void FormEvents_Submit(object sender, SubmitEventArgs e)
{
// Get a reference to the main data source
XPathNavigator root = MainDataSource.CreateNavigator();
// Generate a name for the form to be saved in SharePoint
string formName = Guid.NewGuid().ToString();
// Set the name of the form on the data connection
root.SelectSingleNode(
"//my:formName", NamespaceManager).SetValue(formName);
// Submit the form to SharePoint
DataConnection spConn =
DataConnections["SharePoint Submit"];
spConn.Execute();
// Indicate success
e.CancelableArgs.Cancel = false;
}
}
}
I uploaded the form back to sharepoint and tested with the following result:
Object reference not set to an instance of an object.
at IT_Process_Form.FormCode.FormEvents_Submit(Object sender, SubmitEventArgs e)
at Microsoft.Office.InfoPath.Internal.FormEventsHost.OnSubmit(DocReturnEvent pEvent)
at Microsoft.Office.Interop.InfoPath.SemiTrust._XDocumentEventSink2_SinkHelper.OnSubmitRequest(DocReturnEvent pEvent)
Any ideas?