Custom save Code in InfoPath 2003

To enable or disable save functionality

In the design mode of InfoPath, on the Tools menu, click Form Options. Click Open and Save. Click Open and Save. In the Enable Features section, select the options appropriate for your form. In the Save behavior section, you have a check box option called Save using custom code. If you select this option and click Edit, you create the OnSaveRequest callback function in your form code.

public void OnSaveRequest(SaveEvent e)
{
if (thisXDocument.IsNew == true e.IsSaveAs == false)
{
e.IsCancelled = e.PerformSaveOperation();
e.ReturnStatus = true;
}
else
{
thisXDocument.UI.Alert("The 'Save As' functionality is disabled for forms that are not new.");
}
}
  • ReturnStatus = true, IsCancelled = true The form is not saved, but the OnSaveRequest function is successful.
  • ReturnStatus = true, IsCancelled = false The form is saved, and the OnSaveRequest function is successful.
  • ReturnStatus = false, IsCancelled = true The form is not saved, an error is thrown, and an error message appears to the user.
  • ReturnStatus = false, IsCancelled = false The form is not saved, an error is thrown, and an error message appears to the user.

Comments

Popular posts from this blog

ASP.NET website "Cannot read configuration file due to insufficient permissions" in IIS 7 and Windows Server 2008

Error occurred in deployment step 'Install app for SharePoint': The System Account cannot perform this action.

Embrassing screen sharing interview : SharePoint