Process Infopath Part 1 – Creating your form, schema and project

Open InfoPath designer, and place some fields on the form as shown below:

IPForm

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:

data_fields

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.”

export_source

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.

command1

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.

command2

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.

start_project

Give it a name and a location, then the wizard will walk you through the project setup:

start_project2

start_project3

start_project4

start_project5

 

Once you have completed this, the project is ready for you to begin adding the stuff to make this work.

start_project6

 

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..

start_project9

The next thing to do is add an “Code” tool to the workflow designer.  Drag the tool to right below the “onWorkflowActvated1” command.

start_project7

 

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.

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: