Infopath form with managed code

rated by 0 users
This post has 22 Replies | 6 Followers

Top 25 Contributor
Posts 205
Points 712
Nicolas Posted: Fri, Aug 31 2007 7:54 AM

Is it possible to include .Net code in Infopath browser-enabled forms if you want to use them in Blackpearl?

It's quite easy to develop a workflow based on a codeless Infopath form, but I still cannot figure out how to deploy a form with embedded code, as it has to be approve first by an Sharepoint administrator.

Any idea?

Please remember to change the thread status when a valid answer has been given The statements and opinions made in my postings are my own, and do not reflect the opinions of SourceCode Technology Holdings, Inc. or its subsidiaries. All information is provided as is with no warranties, express or implied, and grants no rights or licenses.
Top 10 Contributor
Posts 1,064
Points 3,286
johnny replied on Sat, Sep 1 2007 6:13 AM

As far as I recall.  Having code in the form makes it browser incompatible. So far we haven't found any way around this.  This has nothing to do with K2 [blackpearl] but rather more of the limitations of browser enabled InfoPath forms with Forms Server.

If anybody has found any new update which makes this possible, I would really like to hear about it.

  • | Post Points: 4
Not Ranked
Posts 7
Points 22

Hi,

I don't believe the above is true regarding code-behind and web campatiablilty of InfoPath Forms. The only issue is that administrators have to upload and activate the form through Central Admin on the SharePoint site for the forms to work.

To deploy a form to SharePoint with code behind publish the form to a common network location(the wizard will take care of this - first option on first screen). Have the administrator upload the form using Central Admin and then activate it for your site collection. This form will then appear a content type which you can use as you wish in any document or forms library.

 

  • | Post Points: 7
Top 50 Contributor
Posts 161
Points 500
japergis replied on Sat, Sep 1 2007 6:53 AM

That is correct, forms with .Net enabled code can be deployed as web enabled forms but they need to be deployed through central administration.

http://spsfactory.blogspot.com/2007/01/walkthrough-publishing-administrator.html

http://technet2.microsoft.com/Office/en-us/library/8285b82e-19db-4408-859f-1430830fe0fb1033.mspx?mfr=true

BlackPearl now publishes the InfoPath form but this does not seem to be accomodated.  Maybe there could be an option added to the wizard which would deploy the InfoPath form to central administration and performing the other actions needed.

  • | Post Points: 6
Top 10 Contributor
Posts 1,064
Points 3,286
johnny replied on Sat, Sep 1 2007 6:55 AM

Excellent pointer.  From this information, it allowed me to find this excellent article - Creating InfoPath Form Templates That Work With Forms Services (http://msdn2.microsoft.com/en-us/library/aa945450(VS.80).aspx) which contains the following.

Note:

After publishing a browser-enabled form template that contains managed code to Microsoft Office Forms Server 2007, to Office SharePoint Server 2007 with InfoPath Forms Services, or to a shared location, the form template must be uploaded and approved by a server administrator before it will be allowed to run.

These other links were also pretty useful in understanding the limitations of Web Enabled InfoPath forms.

  • | Post Points: 4
Top 25 Contributor
Posts 205
Points 712
Nicolas replied on Mon, Sep 3 2007 3:50 AM

Yep Smile

 I have developed many forms with embedded .net code, and they perfectly work in a Forms Services environment (the object model is limited compared to the rich client's, but it's fine).

The problem now is about using them with Blackpearl. When I first heard about the release of the MOSS components for K2.net 2003 in Feb. 2007, I felt like I could do everything with my forms, but unfortunately, forms with embedded code were not supported. Then I put my hope in Blackpearl and... second disappointment: nothing is made to include forms that require administrator approval. Or at least nothing easily visible.

 Are there already K2 Blackpearl specialists who could just say if it's possible? Even if they don't know yet how to do Big Smile

Please remember to change the thread status when a valid answer has been given The statements and opinions made in my postings are my own, and do not reflect the opinions of SourceCode Technology Holdings, Inc. or its subsidiaries. All information is provided as is with no warranties, express or implied, and grants no rights or licenses.
  • | Post Points: 1
Top 25 Contributor
Posts 205
Points 712
Nicolas replied on Fri, Sep 14 2007 11:09 AM

...

 After hours (even days!) of suffering and pain, I have just found how to use web-enabled Infopath forms with embedded code with K2 Blackpearl workflow.

 I may write a real tutorial one day but for the moment, here are the required steps (maybe there's an easier way to achieve the goal, but I havn't found it):

  • 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!!!

It's friday evening, I've just written this after getting successful, so please don't be rude if you spot errors or approximations in this quick and dirty tutorial Smile

Nevertheless, if you're in trouble with a particular step, do not hesitate to ask for details.

 

Please remember to change the thread status when a valid answer has been given The statements and opinions made in my postings are my own, and do not reflect the opinions of SourceCode Technology Holdings, Inc. or its subsidiaries. All information is provided as is with no warranties, express or implied, and grants no rights or licenses.
Top 50 Contributor
Posts 161
Points 500
japergis replied on Sat, Sep 15 2007 11:40 PM
Really cool that you went through this.  Everyone is going to start hitting this.  I hope this is resolved in a SP as part of the deployment process.  Will be kinda of hard to resolve because developers may not admin rights to central administration.
  • | Post Points: 1
Top 200 Contributor
Posts 28
Points 95

Is all this really necessary? Did the hotfix change any of this. 

Using code behind in infopath seems so natural, is it really cross the grain with K2 BP functionality.

Have you tried updating the form?

  • | Post Points: 4
Top 25 Contributor
Posts 205
Points 712
Nicolas replied on Fri, Oct 26 2007 7:23 AM
As far as I know, the different hotfixes didn't solve this problem (it's not a bug, it's a missing feature). This is expected to come with SP1 (H1 2008).
Please remember to change the thread status when a valid answer has been given The statements and opinions made in my postings are my own, and do not reflect the opinions of SourceCode Technology Holdings, Inc. or its subsidiaries. All information is provided as is with no warranties, express or implied, and grants no rights or licenses.
  • | Post Points: 7
Top 50 Contributor
Posts 161
Points 500
japergis replied on Fri, Oct 26 2007 7:43 AM
That will be awesome if they do; my only concern is that the person doing the deployment must have an account that can access central administration.  May not always be the case.
  • | Post Points: 1
Not Ranked
Posts 4
Points 3

Just to make a little phrase correction "This file browser is not made to browse URLs , but it works."

The realy things happen is, when you paste URL location of the template you actually browse to temporary location of the IE. So, in fact you upload the file from local directory.

 Thanks,

Riwut

  • | Post Points: 1
Top 25 Contributor
Posts 272
Points 904
tbyrne replied on Wed, Jan 16 2008 8:54 AM
Does anyone know if this has been addresses with SP1?  I'm just getting started with Infopath integration, and I'd like to know its limitations (or extra hoops I'll have to jump through).  Thanks!
Tim Byrne Clarity Consulting http://www.claritycon.com
  • | Post Points: 4
Top 25 Contributor
Posts 205
Points 712
Nicolas replied on Wed, Jan 16 2008 9:22 AM
No, nothing new on that side. It's still very annoying. I'm currently struggling to put everything in web services methods or SmartObjects... But it's definitely not as powerful as adding code directly in the form template.
Please remember to change the thread status when a valid answer has been given The statements and opinions made in my postings are my own, and do not reflect the opinions of SourceCode Technology Holdings, Inc. or its subsidiaries. All information is provided as is with no warranties, express or implied, and grants no rights or licenses.
  • | Post Points: 4
Top 500 Contributor
Posts 15
Points 49
pauld replied on Wed, Jan 16 2008 11:45 AM
Nicolas, are you shying away from using managed code in your IP forms because of the hassle?
  • | Post Points: 4
Page 1 of 2 (23 items) 1 2 Next > | RSS