Open InfoPath designer, and place some fields on the form as shown below:
As you can see, we have the following columns: student name, enrollment date and an true/false for the student status (Active).
In the classes section, we have a repeating table to show the classes the student is enrolled in. Next, make sure and give some good names to your data fields in the field explorer:
Also note that I changed the group names as well. This will make processing the serialized XML a little more readable when you are coding this workflow (more on this later).
Now that you have your form setup, we need to export the source files somewhere and extract the XML schema to a class file we can use in a workflow. To do this, you must go to the File menu, then click Publish, and then “Export Source Files.”
It will then prompt your for a location to save the files. I save them in a directory in the same location as the InfoPath form in a folder called “sources”.
An InfoPath file is really a collection of other files. If you were to rename your XSN file to a CAB file, then you can see that the XSN is really comprised of many files like any CAB file or ZIP file. The one we are concerned with is the “myschema.xsd” file. This is the data structure from the InfoPath form. As it stands now, the file isn’t really usable in a workflow, so we have to run a little process on this file to turn it into a data class file we can use inside our Visual Studio project.
To do this, you must have Visual Studio installed. From the start menu, run the Visual Studio command prompt.
Once you have the command prompt open, navigate to the location you saved the source files, and type the following command:
xsd.exe myschema.xsd /l:vb /c
What this does in this case is create a visual basic class file. if you choose to use C-Sharp, then the command would be “xsd.exe myschema.xsd /l:cs /c“, since the “/l:xx” command line switch tells it what language to convert it to. The “/c” command line switch tells it to create a class file.
As you can see here, it created a vile called “myschema.vb”. This is the generated class file we will use in our project.
Next, we need to create our project.
In Visual Studio, go to File | New project. You will then be presented with several project types. We are looking in this case for a SharePoint 2010 Sequential Workflow VB.net project.
Give it a name and a location, then the wizard will walk you through the project setup:
Once you have completed this, the project is ready for you to begin adding the stuff to make this work.
Next, we need to add the generated class file into our project so we can use it. in the project explorer, right-click the workflow1 item, and select add | existing item…
Navigate to the location you exported the InfoPath files, and add the “myschema.vb” file to the project..
The next thing to do is add an “Code” tool to the workflow designer. Drag the tool to right below the “onWorkflowActvated1” command.
At this point, we have setup the main things we need to get this workflow off the ground. Coding the workflow is in Part 2.