tags:

views:

206

answers:

3

I need to save my InfoPath form regardless of whether the required fields have been entered when the user clicks on a button. Is there a way to turn off validation for the InfoPath form temporarily?

A: 

you will have to write you own validation code in the code behind file.

and have it vlidate when the user clicks the submit button or not when you just want to have the code.

another approach is to have the fields to allow null values and only validate when they have text in them. this would not require custom code.

Chris Jones
+1  A: 

By save i assume that you mean that you want to save the xml data file locally rather than submit your form to a datastore (webservice, sharepoint etc)

in tools>form options you can enable "save/save as" on the form (i think this is on by default) it will complain that there are validation errors but still allow you to save.

there is also save via code-behind using which will not go through the validation routine but will require that the form is fully trusted as it needs access resources that Infopath forms are normally restriced from using.

VB.Net Me.SaveAs("c:\temp\myfile.xml")

C# this.SaveAs("c:\temp\myfile.xml");

Or as Chris suggested allow nulls as part of your data source.

Nathan Fisher
A: 

I've done similar by including radio buttons on the form with the labels 'I have completed this form and am ready to submit' and 'I am not done with this form. Save it and finish later'. Each validation then look something like (validation OR saveOptions == 'complete'). The submits similarly use this field to decide what actions to take.

Daniel

related questions