Skip Ribbon Commands
Skip to main content

Blog

:

Quick Launch

Blog > Posts > Disable InfoPath 2010 Validation Errors on Submit
November 13
Disable InfoPath 2010 Validation Errors on Submit

​Problem:

So, I am building a form that will write line items to a Task List.  The form has multiple tabs and has a number of required fields.  These required fields should be filled out prior to formal submission of the form.  However, I need to be able to submit data back to SharePoint for these tasks regardless of the validation.

Solution:

I found a great article here:

http://stackoverflow.com/questions/1273293/infopath-submit-functionality

Code:

public void SaveAsDraftButton_Clicked(object sender, ClickedEventArgs e)
{
    this.Errors.DeleteAll();
    this.Submit();
}

I had to make some changes to this for it to work in my scenario.  I had to backup the errors prior to deleting them because they were valid. 

So I had to do this:

 

     public List<BackupFormError> BackupErrors(FormErrorCollection Errors)
     {
         List<BackupFormError> backupErrors = new List<BackupFormError>();

 

         foreach (FormError formError in Errors)
         {
             BackupFormError backupError = new BackupFormError();
               
             backupError.Context = formError.Site;
             backupError.Name = formError.Name == String.Empty ? formError.Site.LocalName : formError.Name;
             backupError.Message = formError.Message;
             backupErrors.Add(backupError);
         }

 

         return backupErrors;
     }

 

The Errors collection on the form is a static reference (I believe).  The FormErrorsCollection is also an abstract type meaning I couldn't create a variable to hold the errors as a backup and then write them back.  Instead, I created a basic inline object and added those objects to a Generic List.

It worked very well, with the exception that the .Name property of the Error was always blank.  When creating a new FormError, it would throw an exception when the object was created with a blank .Name property.

Comments

Re: Disable InfoPath 2010 Validation Errors on Submit

This is exactly what I was looking for. Thank you.
 on 11/21/2013 12:55 AM

Add Comment

Items on this list require content approval. Your submission will not appear in public views until approved by someone with proper rights. More information on content approval.

Title


Body *


3=8=? *


to keep the bots out

Attachments