Friday, August 04, 2006

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.

No comments:

ASP.NET MVC - Sport Facility Booking system

  The project relies on some external service providers. Thus accessing them via their API requires authentication. An API Key need to be su...