web based Infopath Form with code behind

  • 22 November 2007
  • 7 replies
  • 0 views

Badge +8
Is it possible to use a webbased infopath form with code behind in the k2 process?

7 replies

Badge +8

Yes you can but you have to do a few things.  Check out the following...  jason


http://k2underground.com/forums/thread/18335.aspx

Badge +8

I have done the steps below. But when i switch to "View all Site Content" I have no "K2 Blackpearl Forms template" or something like this. So I dont know where the Content Type is?


Has anyone an idea? What can be wrong!
thx
Jochen


 


Create a Infopath form aimed to be open in a browser
Design your form (add the groups and fields, the data connections, etc.) BUT don't add .Net code now (it may work but that's not how I did it)
Create your K2 project in VS 2005
Design your workflow just like in the Infopath tutorial provided with the Blackpearl documentation until step 5; this step of the tutorial is the one where you must re-design the form to adapt it. Add your .net code now. When you're done, do not finish the Infopath Integration Wizard.
In the Infopath Integration Wizard, edit the properties associated to your forms (ie "publish to") and set the form library where you'd like to see your form published. Select "content type" instead of "form library template", and do not forget to set the opening program as "web browser".
Finish the wizard, and deploy your project
Now go to the form library, the "settings", and delete all the content types set for this library.
On the same site, click on "View all site content", you should see a "K2 Blackpearl Form Templates" or something like this. Open the lib. It contains the form you've just deployed. Right-click it, and copy shortcut to this XSN file.
Go to your MOSS Central Administration, "Application Management" --> "Manage Form Templates", and click on "Upload a form template".
Click the "Browse" button, paste the shortcut, and click "Ok". This file browser is not made to browse URLs, but it works.
Confirm the upload of this form template (you can verify it if you want, but it's quite useless)
Activate it to your site collection
Go back to your site, and to your form library
Click "settings", and add an existing content type. In the list, you should find the name of your form (eg: "my form"), plus the name of your form with a suffix which should be "1" (eg: "my form1"). Select this one (the first one is the content type automatically deployed by Blackpearl, do not select it as it's not admin-approved)
Now go back to the form lib, create a new instance of the form, and.......... it works!!!
Badge +8

I must probably be wrong but I thought the K2-related libraries (Form Templates and Data Connections) were created the first time you deployed a process definition with integrated Infopath form. It's strange.


I will try on a blank site collection.

Badge +8

I have removed the form code and tried it again to make the form browser based (as template, not as content type). When I open the form in browser I always get the message "Cannot access dataconnections". I can click "continue" and the form is opened in browser. But when I try to submit the form, there is an error message.


 When I do the same actions in Infopath Client, there is no problem.
So I think there is a problem with the k2 data connections.


Thx
jochen

Badge +8

Hi Jochen,


If your web form doesn't make use of UDC files, it cannot reach the K2 web services (including the one used to submit the form), whereas it's not necessary in a rich client context as it can call web services directly.


I must admit I have the same problem in my new site collection, which I don't really understand. In my previous site collection, when I created an Infopath-based process, I had a K2 data connections library which was configured automatically by K2. Now there's no such library.


I will continue my investigation.

Badge +8

You have to do some workaround.


Have a look at these posts:
http://k2underground.com/forums/thread/20012.aspx


 


--> This post is on the wrong position. How can I delete my post?

Badge +6

Just to follow this thread: have a look at this post in the "HOW TO K2" from Chris: Using “code behind” with InfoPath forms, SharePoint and K2

Reply