Friday, September 19, 2008

Deploying InfoPath forms using Features – the Right Way

Same version of the Post is avaliable in this Link. Formatting Adjusted.

A week back couple of my friends was asking is there a proper way to deploy the InfoPath forms to the server, Way other than File -> Publish - > SharePoint server with or without forms server. I did a quick search and was not lucky, came to a lackadaisical conclusion that there is no other way. But whenever I deploy workflows with InfoPath form I see a new solution that adds itself to the Solution Store. By this I know for sure there is some other way to deploy InfoPath forms. First thing want I wanted was to get the Solution out of SharePoint and see what's there inside, Again for this there is a tool through which you can do it [I lost the url from where I got it] or hardly 10 lines of code is all what you need.

To my surprise there is indeed a way to do it, well let's see how. What I got out of that solution is a feature, what's in it [Image speaks louder than words, image with comments even louder ;) ]

Feature.xml

#########All usual Stuff ###########

<?xml
version="1.0"
encoding="utf-8"
standalone="yes"?>

<Feature
Id="8ad77502-3602-6e81-c4de-8c7f674c4466"

Title="IPDeplotyment"

Description="$Resources:ipfscore,XsnFeatureDescription;"

Version="1.0.0.0"

Scope="Site"

DefaultResourceFile="ipfscore"

#########Here is the hero who does what we need ###########

ReceiverClass="Microsoft.Office.InfoPath.Server.Administration.XsnFeatureReceiver"

ReceiverAssembly="Microsoft.Office.InfoPath.Server, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"

xmlns="http://schemas.microsoft.com/sharepoint/">

<ElementManifests>

<ElementManifest
Location="Elements.xml" />

<!-- Name of the IP Form

Note:Actual workflow generated feature has a different name-->

<ElementFile
Location="solution.xsn" />

</ElementManifests>

<Properties>

<!-- The Name of the Feature - Infact after you have deployed the WF to sharepoint there will be a

feature by this name that gets added -->

<Property
Key="FeatureName"
Value="FT-01-8ad77502-3602-6e81-c4de-8c7f674c4466" />

<!-- This is going to the File name with which you have Publised from IP Client / Added to the Workflow.xml

if you are going to deploy the IP forms that are not coupled with the WF you can safely ignore the below tag-->

<Property
Key="OriginalFileName"
Value="IPDeplotyment.xsn" />

</Properties>

<ActivationDependencies>

<!-- Just to make sure that you have Enterprise feature turned on-->

<ActivationDependency
FeatureId="C88C4FF1-DBF5-4649-AD9F-C6C426EBCBF5" />

</ActivationDependencies>

</Feature>

Element.xml

################### You are Right its again another File Provisioning in to SharePoint Lib #####################

<?xml
version="1.0"
encoding="utf-8"
standalone="yes"?>

<Elements
xmlns="http://schemas.microsoft.com/sharepoint/">

############# Be sure to put the location as FormServerTemplates############

<Module
Name="XSN"
Url="FormServerTemplates"
RootWebOnly="TRUE">

<File
Url="solution.xsn"
Name="IPDeplotyment.xsn"
Type="GhostableInLibrary" />

</Module>

</Elements>

Well here is the stripped out version of the above file

<?xml
version="1.0"
encoding="utf-8"
standalone="yes"?>

<Feature
Id="8ad77502-3602-6e81-c4de-8c7f674c4466"

Title="IPDeplotyment"

Description="$Resources:ipfscore,XsnFeatureDescription;"

Version="1.0.0.0"

Scope="Site"

DefaultResourceFile="ipfscore"

ReceiverClass="Microsoft.Office.InfoPath.Server.Administration.XsnFeatureReceiver"

ReceiverAssembly="Microsoft.Office.InfoPath.Server, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c"

xmlns="http://schemas.microsoft.com/sharepoint/">

<ElementManifests>

<ElementManifest
Location="Elements.xml" />

<ElementFile
Location="IPDeplotyment.xsn" />

</ElementManifests>

<Properties>

<Property
Key="FeatureName"
Value="FirstIPFeatureWayDeployment" />

</Properties>

<ActivationDependencies>

<ActivationDependency
FeatureId="C88C4FF1-DBF5-4649-AD9F-C6C426EBCBF5" />

</ActivationDependencies>

</Feature>

Element.xml

<?xml
version="1.0"
encoding="utf-8"
standalone="yes"?>

<Elements
xmlns="http://schemas.microsoft.com/sharepoint/">

<Module
Name="XSN"
Url="FormServerTemplates"
RootWebOnly="TRUE">

<File
Url=" IPDeplotyment.xsn"
Name="IPDeplotyment.xsn"
Type="GhostableInLibrary" />

</Module>

</Elements>

Steps in Short:

  • Develop your IP form.
  • Publish it to the network location as how you do to upload to the Central Administration Upload Form Templates.
  • Create one Feature.xml, Element.xml as defined in the article [Sorry how workflow does ;)].
  • Put in the IP form and create a feature out of it.
  • Its all.

11 comments:

Gagan Kapoor said...

hi Senthil,
this is a great post. Can u clarify how do you make this available to a workflow. Basically i m trying to create a content type with infopath form as the template. I did achieved this successfully using feature. but i need a way to store the infopath form field data into site columns which i create using the same feature.Also i would attach a worklow to this contenttype.
thanks in advance.

Senthil Kumar said...

Hi Gangan,

To answer your question you I assume you are using the InfoPath 2007 version.

1.Form Field to the Site Column Refer to this link
http://skurocks.wordpress.com/

2.For Associating the WorkFlow to the ContentType use this Link
http://social.msdn.microsoft.com/Forums/en-US/sharepointdevelopment/thread/15cad70e-c100-4cb8-8ba5-7d1ab483d281/

Thanks & Regards
Senthil

Anonymous said...

, christine mendoza nude, =))), maggie q nude, vksft, thandie newton nude, 957609, erica cerra nude, olfy,

Anonymous said...

, michelle gellar sex scene, :PP, jean louisa kelly nude, zdwps,

Anonymous said...

, christina milian nude, 140,

Anonymous said...

, maura tierney nude, ckdx, jessica biel sex scene, 248,

Anonymous said...

comment2, sophie monk nude, cbmn,

Anonymous said...

comment3, billie piper nude, zmgixi, mayra leal nude, zlgm,

Anonymous said...

comment3, erica cerra nude, 5177,

Anonymous said...

comment4, laura vandervoort nude, 0543, angelina jolie nuda, >:-(((, lindsay lohan nackt, 753, brooke shields naked, 45866,

Anonymous said...

, suzi perry nude, 175985, rihanna naakt, ksm,