Once the file is available in the project, you have the capability to bind the data source to the .NET class and access the data in a standardized format. If you ever make changes to your InfoPath data source, you’ll need to rerun the xsd.exe command against the new “schema.xsd” file.

Upload Form Template to a SharePoint Form Site

Figure 6 – Publish

Figure 7

Figure 8 – Select SharePoint Server

Figure 9

Figure 10

Figure 11

Figure 12

Figure 13

Populate and Upload Form Data

Populate the myFields class with dummy data. The class was created using the XSD application.

What is the trick to programmatically setting checkbox and date fields on the form?

The schema file shows my checkbox (chkTemp) as boolean and I set it to True. The code shows no errors and runs, but the box is not checked in the finished form. The same is true for my date field (dtImpDate). The schema shows it as a date data type and I set it as such but it doesn't show up on the form. Aside from this, the code is working great. All my text boxes fill as expected. What am I missing?

Figured it out. I had to change the data types on the properties menu of the check box and date field during design. I changed them from boolean and date to string. Then I set the cleared and checked fields to be 0 and 1. I recreated by schema and republished my form. Then I changed my code to this and it worked. I'm assuming you don't have to use 0 and 1 since it is a string, but it is what I'm used to so it works.

Hi, I followed this steps and made it as a web service in my sharepoint server. Everything went smooth except when I incorporate a workflow into the form library. Workflow started but it shows 'Failed on Start'.. However, It works fine if I start the workflow manually. Anyone experienced the same issue of mine?

I have a form template that was converted from word, and it has a bunch of fields (probably for accepting null values) that pair up with the fields designated on the from. for example, I have a chkOT field (checkbox true/false). in the xsd, there is a chkOTSpecified field (true/false).

When I build the xml for a form to publish to a sharepoint form library, unless i specify chkOTSpecified = true, chkOT does not retain it's value when the xml is put into the form library.

How can I get rid of this nasty? (assuming that posting a value in a form should just happen...)
I understand why this is here, just don't understand why there is no interface to declare that ALL the fields are specified...

Any answer to this question? I read elsewhere that one has to change the datatypes of the boolean fields on the infopath form to strings. This could be quite problematic if you have lots of these fields. For me changing all the fields to string datatype is not an option.

The issue that I'm noticing is that if I chose to publish some of columns (when I publish the form to the sharepoint site) then the columns will not show the values (I'm guessing that is due to the missing "my" before the fields).

Is there a way to work-around that? or am I doing something incorrect on my side?

Thank you so much - That helped me a lot. Saved one more day's time. I have already wasted quite some time on this. Without this the Digital Signatures setup in the Infopath document werent working.
Many Thanks again.

I made a few minor adjustments to make it work for me:
1. I didnt use memorystream.GetBuffer(). passing the memorystream without calling GetBuffer removed trailing whitespace from the XML document for me. This trailing whiteapce was, for some reason, causing the form to be recognized as invalid XML :P

2. I set "writer.Format = Formatting.Indented" this may not be required, but you will find in your unit tests that without setting the format properties of your textwriter, the XML does not have any new lines or indenting which is a nightmare for debugging.

One last thing I ran into: security problems. If you try to run this code from a non-sharepoint loaction (such as a windows program or a plain asp.net site) you will run into security exceptions. I fixed that by modifying your code slightly:

// lastly, if you want to modify any of the item fields get the item from the thisFile instance and set/update the item.
SPItem spItem = thisFile.Item;
spItem["Modified"] = String.Format("{0:MM-dd-yyyy}", (DateTime)dtFldDateConvert);
spItem.Update();