There are a lot of instructions out there on how to publish InfoPath forms with code behind to SharePoint. However, I have not come across any complete documentation on how to do this from beginning to end with K2 BlackPoint to SharePoint. One of the problems that will usually arise is that if you have multiple activities with in the K2 workflow, you will not be able to surface the IP form to the browser in succeeding steps. Usually, the form will surface in the browser on the first activity and any subsequent activities will result in the IP form trying to open in the IP client. If you follow the steps that I am demonstrating, you will be able to successfully publish and use the IP forms with code behind in combination with the K2 workflow. One thing to note, this process is applicable to K2 BlackPoint and also K2 BlackPearl.

Enabling SSL on SharePoint Server

Prerequisite: Certification Authority (CA) needs to be installed on the Server or need access to a CA.

For more information regarding CA, please refer to the following links:

After you have created your InfoPath form that is browser-enabled and does utilize code-behind, you will need to log in to your SharePoint server. Open IIS manager and navigate to the SharePoint web application. Open the properties of this website and select the Directory Security tab. In the Secure communications section, verify that a certificate exists by clicking on the View Certificate button (figure A) and making sure the certificate is valid and issued to the website host-header. (figure B) If there is not a valid certificate, you will need to obtain a valid certificate for the site.

Figure A


Figure B


Create InfoPath Form Library

Log on to your SharePoint site as a Site Collection Administrator and create an empty Form Library. Once you have created the library, go to the form library settings and click on the libraries Advanced Settings. In the Content Types section, select Yes for the management of Content Types. In the Browser-enabled Documents section, select Display as a Web Page option. Click Ok.


Designing the InfoPath Form Template in K2

Assuming you have created a blank process in K2, click on the Process Wizard tab and drag InfoPath Integration onto the K2 process. Click on Add to insert a new InfoPath Form template. Configure the wizard screens as follows:

InfoPath Form Source Location
  1. Located at: Local or Network Location
  2. Location Path: path where your InfoPath form resides


InfoPath Form Deployment Location
  1. Publish to: SharePoint Form Library
  2. SharePoint Site URL: select your SharePoint site where the form library you created resides
  3. Form Library: Click on Browse and select the form library you created earlier
  4. Select Add as library template
  5. Form Client: Web Browser


Finish out the InfoPath Integration wizard as normal and save the K2 project. Deploy the K2 solution as normal and verify that it was successful.

InfoPath Form Directories

At this point, a published form directory needs to be created. Create a folder on your local machine (i.e. C:\InfoPath Published Forms). This folder will be the “Published From” folder (will be referenced as IP_FROM). The folder that is “Published To” is the location of your K2 project, and browse to the InfoPath Form Templates folder (will be referenced as IP_TO).

Once you have deployed the K2 process successfully, browse to the IP_TO folder and copy the XSN template and paste it to the IP_FROM folder.

This next few steps is a workaround to keep the template file with the same name. Right click the XSN template in the IP_FROM folder and click Design.

(The following steps will only need to happen the first time the form is copied over to the IP_FROM folder. If you don’t receive the error, skip these steps below and go to the Signing and Publishing the InfoPath Form section)

You may receive an error message the first time that looks like the following:


Click OK and the form will open. Follow these steps:

  1. Go to File/Save As and save the file with a different name to the same directory that you just opened it from
  2. Close the form
  3. Locate the original template that you clicked Design and remember the name of the form template (should be the same as in the IP_TO folder) and delete the template
  4. Right click the new template that saved in step 1 and select Design.
  5. Go to File/Save As and save the file with the same name as the one you deleted in step 3
  6. Close the form
  7. Delete the form you saved in Step 1.
  8. Right click the form you saved in Step 5 and select Design


Reason for the steps above is that when publishing the form, SharePoint will use the name of the form as the content type, and we want it to be the same name as the one in the IP_TO folder.


Signing the InfoPath Form

The form should be in design mode from the IP_FROM folder as mentioned in the previous section. Here are the steps to publish the form:

  1. Go to Tools / Form Options and select the Security and Trust category
  2. Make sure the form is set to Full Trust
  3. Under the Form Template Signature section of the Security and Trust category, make sure that the checkbox is checked for Sign this Form Template and a certificate is associated with it (see figure C).
  4. Go to the Programming category of the form options and verify the project location is correct and that it has the project file name (.csproj) as well (see figure D).
  5. Got to the Compatibility category of the form option and verify that the box is checked to open the form template in a browser (see figure E)
  6. Click OK, but DO NOT close the InfoPath Form.


Figure C


Figure D


Figure E


Publishing the InfoPath Form

Once you have completed verifying the correct code behind is associated with the form and have signed the form, you are now ready to publish the form.

  1. Go to File / Publish on the InfoPath form

2.  Select the first option where you want to publish the form template to a SharePoint server, click Next.


3. Type in the location of your SharePoint site, click Next

4. Make sure the box is checked for Enabling the form to be filled out by using a browser, click Next. k2_ip7 5. Browse to the location of the form template that is in the IP_TO folder (the K2 InfoPath Form Templates folder of the project).

Note, first time through these steps, the wizard will ask you if you want to overwrite the template, go ahead and save over the template.

6. If you want to add columns, to the content type, you can do so here, else click Next. k2_ip9 7. Verify the info is correct and click Publish. k2_ip10
8. Click Close and then close the InfoPath Form. k2_ip11    


Uploading and Activating InfoPath Form on SharePoint

At this point, you are ready to upload the form template to SharePoint. Open up an instance of SharePoint Central Administration and browse to Application Management. Locate the InfoPath Form Services section and click on  Manage Form Templates. Click on Upload Form Templates link. In this screen, where the text box is to insert the file name, click the Browse button and navigate to the IP_TO folder where you just finished publishing the form to. Select the XSN file you published and click Open.


Click the Upload button and wait until the next screen appears showing the form uploaded successfully.


Once you click OK, it will return you to the Manage Form Templates page and verify the form you just uploaded is in the Ready status. If it is not, refresh the page until it is.

Navigate to your Site Collection and complete the following steps:

  1. Click on Site Actions of the site collection.
  2. Select Site Settings
  3. Under the Site Collection Administration section of the site settings, click on Site Collection Features.
  4. Locate the form template you just uploaded and click Activate.
  5. Now browse to your Form Library that you created earlier and select the form library settings
  6. Locate the Content Types section and click on Add from existing site content types.
  7. In the available content types box, select the content type (your InfoPath form name) and Add it to the box for content types to add and click OK.
  8. Click on Change new button order and default content type and uncheck the box to make the FORM content type NOT visible and change the position from top of your new content type to 1 and click OK.


This completes the steps to publish and upload an InfoPath form with code behind to SharePoint. You can now browse to your form library and click New and your form will now open in the browser!