There are two approach to publish Code enabled Infopath form into SharePoint,
- Publish as a Sandbox solution: Malicious code cannot harm the server as the code is run in a sandbox environment and site collection administrator can directly publish form from inforpath designer.
- Publish as an Administrator approved from template:Forms run under full trust and farm administrator can deploy this solution.
There are advantages using both of these approaches based on the solution you develop. Recently while publishing a code enabled form as a sandbox solution from infopath i faced the following error,
“The form template has been published to the server but it can only be opened in InfoPath Filler.
There is an error in the InternalStartup method of form code.
There may be additional error detials in the Design Checker task pane.”
But infopath design checker doesn’t show any error. After researching one full day i give up and try another approcah which i am going to share toady.I am going to publish an administrator approved form template which has custom code behind. So here are the steps :
- Select Publish from Infopath designer and choose Publish to a SharePoint Server
- Enter your site URL where you are going to publish the form

infopath form service URL
3. Select Administrator approved form template from the wizard

administrator approved form template
4. Choose a location at your computer to save the form and give a name( for example, leave application )

save template in your local pc
Now,
- Go to SharePoint Central administration>General application settings>InfoPath form services>Upload form template.
- Select the form template you have saved previously (at step4) from your computer by Browsing and click upload when you are done.
- A notification message will come up and click Ok to finish the step.
You are done almost. Now how to make use of this form?? Great question indeed. Okay lets see how to do that.
To use the form template on your site,
- Go to your site collection administration page>Site Collection Features
- Activate the form template feature(leave application; in this example )
- Now create a document library and go to Library settings>Advanced Settings and Allow management of content types? to Yes and the rest of the settings as per the image below

management of content type
leave the rest of the settings as default.
4. From content type section click Add from existing site content types and choose the template you uploaded(leave application) and click OK when your are done.

add leave content type
5. Now go to the document library and try to create new document

leave application as content type

leave application form
Hope this helps.
Advanced Settings
Like this:
Be the first to like this post.