Using “code behind” with InfoPath forms, SharePoint and K2
IP and Codebehind

 

 

Some additional great info

http://www.k2distillery.com/2008/12/deploy-infopath-as-feature-with-managed.html

http://www.k2distillery.com/2008/10/deploy-infopath-as-feature.html

Also from the K2 documentation, check out the step by step instructions.  (be aware you will also need to have some type of digitally signed form in many cases for this to work 100%)

InfoPath integration using Code Behind

When integrating K2 blackpearl with InfoPath FormServices and the InfoPath form contains Code Behind the following steps will need to be performed:

1. Create your Form, add your C# or VB code, set it to Full Trust and save the template on the local machine

2. Open your K2 Project

3. Open the InfoPath Process Integration Wizard

4. Select Add

5. Browse to your Template saved in step 1

6. On the Deployment Location page select Local or Network location

7. Complete the Add InfoPath Template and InfoPath Integration wizards

8. Deploy your process when done with your design

9. After successful deployment browse to the Deployment Location selected in step 6

10. Right Click the file and select Design

11. Select Publish from the File menu

12. Enter your Site URL and click Next

13. Select Enable this form to be filled in Using a browser and Continue to the next page

14. Enter the Template filename which will have to be uploaded by an administrator using the Central Admin and complete the rest of the wizard

15. Close InfoPath

16. Open the MOSS Central Admin site

17. Navigate to Central Admin > Application Manager > Manage Form Templates > Upload Form Template

18. Browse to the File saved in step 14 and select Upload

19. When this completed navigate to Central Admin > Application Manager > Manage Form Templates

20. Find the template uploaded in the previous step, open the file’s drop down menu and select Activate Template on Site Collection

21. Select the site on which you would like to use the template and click on OK

22. Browse to the site on which you activated the Template and navigate to the library on which you wish to add the template as a content type

23. Ensure that the Library is set to display as a Web Page and apply the changes

24. Still on the Library settings page find the Content Types Section and select Add from existing site content types

25. Add the Content Type that you enabled on the Site Collection in step 22

26. Navigate to the Document Library and Open the content type added

27. This should now open the Browser


Posted Mon, Jun 29 2009 3:49 PM by chrisg

Comments

Johnny's K2 Blog wrote Using "code behind" with InfoPath forms, SharePoint and K2
on Tue, Jun 30 2009 9:09 PM

Saw that there was this new "How-to" post on using code behind in InfoPath forms. Quite a useful reference

sriwantha wrote re: Using “code behind” with InfoPath forms, SharePoint and K2
on Thu, Sep 3 2009 4:00 AM

Okey guys… this works perfect until you get a task action in the “work list” web part. You can of course complete the workflow by clicking the task action menu and then directly giving the action command. But when you try to open the InfoPath form from the k2 task action (k2 task action list item--> (drop down menu)--> open) browser downloads the InfoPath file and then try to open it through the InfoPath client. (It never get opened in the web browser !!!!!)  Now our form ,being a full trusted one, fails to open by giving an error message as follows.

“The form template is trying to access files and settings on your computer. InfoPath cannot grant access to these files and settings because the form template is not fully trusted. For a form to run with full trust, it must be installed or digitally signed with a certificate.”

The problem now is HOW TO --> open the form in browser directly from k2 task action ?

Note: Your method works only during initial submission. After that you can’t open the InfoPath form the browser

Sriwantha Sri Aravinda Attanayake

sboldt wrote re: Using “code behind” with InfoPath forms, SharePoint and K2
on Fri, Sep 4 2009 10:53 AM

I get the same issue the Sriwantha mentioned. When I go to the form library and select a new IP form, it opens up fine in the browser. However, when it proceeds to the next step in the workflow, when I go to the K2 worklist and try open the form there, it opens it up in IP.

Steve

Jochen wrote re: Using “code behind” with InfoPath forms, SharePoint and K2
on Tue, Sep 8 2009 6:49 AM

I have tried a workaround..

First I designed a "normal" InfoPath process with no code behind and deployed the process as usual. Then I added code to my form and deployed the process and the form as it is mentioned above. I acvitvate the server form template to my site collection and added this InfoPath form content type to the form library where I first deployed the "normal" InfoPath process to.

It worked. I hope this was not only luck...

sboldt wrote re: Using “code behind” with InfoPath forms, SharePoint and K2
on Wed, Sep 16 2009 12:07 PM

Ok, I finally got it. Here is the way that I was able to get it all working. Thanks to K2 support help and a combination of tweaks, I was able to get the forms to pull up in the browser at each step in the workflow. I wrote it all down in my blog which you can find here:

http://www.stevenboldt.com/blog/post/2009/09/15/How-to-publish-K2-BlackPoint-workflow-InfoPath-Form-Services-with-code-behind-to-SharePoint.aspx

Cheers!

Steve

Jochen wrote re: Using “code behind” with InfoPath forms, SharePoint and K2
on Fri, Sep 18 2009 12:22 AM

Very good post. This solved the problem.

I also had contact with K2 support concerning this issue. Your solution and the solution I got from K2 support are quite the same. Well done!

Ramble On wrote [HOW-TO] Deploying a K2-Infopath form as a Sharepoint administrator-form...
on Mon, Nov 9 2009 8:30 AM

... or what is behind the "Publish to: Local" in the Infopath Integration Wizard. In some cases

Ramble On wrote Infopath Administrator-Approved Forms and K2 processes
on Thu, Nov 12 2009 1:47 AM

... or what is behind the " Publish to: Local or Network Location " in the Infopath Integration