I recently had an issue where it was necessary to only save some of the fields on an InfoPath form back to the form library. To do this required a combination of custom code and submission to a form library using a data connection.

3. In the submit options select Send form data to a single destination and choose SharePoint document library from the dropdown

4. Click Add to add a new data connection and follow the wizard to set this up to submit your form to the required library

5. Now that the data connection has been set up, select Perform custom action using Code and click the Edit Code button - this will create a submit method in the code behind file

6. In the submit method place the code to do the custom "stuff" and then submit the form to the data connection. The code will look something like:

public void FormEvents_Submit(object sender, SubmitEventArgs e)
{

//remove values from the form that you don't want to be saved
XPathNavigator xPnName = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:Name", NamespaceManager);
xPnName.SetValue("");

//submit the form using the data connection

DataConnections["Main submit"].Execute();

//set e.CancalableArgs to be false once form has successfully saved

e.CancelableArgs.Cancel = false;
}

To give the form a unique filename and allow updates to saved forms do the following:

1. Create a new xml node called dtNow, give it a default value of now() and uncheck the Update this value when the result of the formula is recalculated box.

2. Go to Data and Data Connections and Modify the submit data connection created above.

3. In the Filename field add concat(userName(), dtNow) and check the Allow overwrite if the file exists checkbox.

Finally, convert the data connection used to submit the form to be centrally managed as described here