Wednesday, March 12, 2008

Assigning InfoPath Form template to forms library in a custom site Definition

I ran into a very interesting issue today.
It should be very straight forward to assign your custom xml form as a default template for forms library in your custom site definition.
And I’m not talking about globally overwriting the default template.xml, I just want form libraries within sites created from my custom site definition to use this template.
If you are interested in the steps, here they are:
You open your ONET.xml and locate the following lines (if you don’t have it, you can add it)

<DocumentTemplate XMLForm="TRUE" Path="STS" DisplayName="$Resources:core,doctemp_BlankForm;" Type="115" Default="TRUE" Description="$Resources:core,doctemp_BlankForm_Desc;">
<DocumentTemplateFiles>
<DocumentTemplateFile Name="doctemp\xmlforms\blank\template.xml" TargetName="Forms/template.xml" Default="TRUE" />
</DocumentTemplateFiles>
</DocumentTemplate>

NOTE: If you have custom list definition for your library, make sure TYPE property matches DocumentTemplate Type property.

So, I would expect that by simply adding my xml file to C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\1033\STS\DOCTEMP\XMLFORMS\BLANK\ directory and modifying the Name property to point to my xml file instead of template.xml, I would get it working.
To my surprise, the template that was picked up by my library still was the original template.xml
Well, the solution turned out to be really simple, move your custom xml template file OUT OF “\BLANK\” directory, simply put it into C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\1033\STS\DOCTEMP\XMLFORMS\ and modify DocumentTemplate’s Name property to point to it.
In my case it looked something like that “C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\1033\STS\DOCTEMP\XMLFORMS\customForm.xml”
Save ONET.xml, reset your IIS.

5 comments:

jborean said...

That seems like a lot of work...

I did the same thing by just publishing the form to the new library. I also went a step further to use manage content types to set up multiple forms that could be selected from the "new" drop down in the library by name/type.

jborean said...

That seems like a lot of work...

I did the same thing by just publishing the form to the new library. I also went a step further to use manage content types to set up multiple forms that could be selected from the "new" drop down in the library by name/type.

Natalya Voskresenskaya [SharePoint MVP] said...

I agree with you, the way you have described is another way to do it. In my case, lots of sites from this definition would be provisioned by end-users through workflow and they are not expected to go through all this hustles, they don’t even know what a template is, and they don’t have sufficient rights to the library to assign it. All they expect to see is specific forms library with this default template.

Purvish Shah said...

u looking ar8

Unknown said...

Good job, Natasha.
I also need to provision it and send to a client that will deploy across multiple sites.