Friday, December 16, 2011

Custom Form deployment in sharepoint 2007

I have faced a problem today... FOr a customer I 'm actually working on sharepoint 2007 (sigh)...

I have to customize fully a huge form (that contains 200 fields) by adding tabs. It's not the topic but I'm doing it doing jquery (and that rocks).

In order to do it,you just have to open your editform.aspx newform.aspx and dispform.aspx, and to replace it with new forms using a feature that copy the new form in the list form folder. The topic of this blog is the content of those aspx file.

To create it, I have simply copied the content of my old EditForm . I have erased everything contained in the PlaceHolderMain .

And I have (in sharepoint Designer) inserted the form content using :
insert > Sharepoint Control > Customize a list form and I have selected my list...

I have added my tabs, everything works fine on sharepoitn designer but...mmm I want to deploy it on 100 sites containing the same list...
Should I do it manually? obviously no... But if you try to do it directly you will face a bug saying
"Unable to display this Web Part. To troubleshoot the problem, open this Web page in a Windows SharePoint Services-compatible HTML editor such as Microsoft Office SharePoint Designer. If the problem persists, contact your Web server administrator. "

If you look inside your form you will find :
<ParameterBinding Name="ListID" Location="None" DefaultValue="{ID OF YOUR LIST}"/>That you have to replace by
<ParameterBinding Name="ListName" Location="None" DefaultValue="NAME OF YOUR LIST"/>

<WebPartPages:DataFormParameter ParameterKey="ListID" PropertyName="ParameterValues" DefaultValue="{IDOFYOURLIST}" Name="ListID"></WebPartPages:DataFormParameter>

that you have to replace (4times) by

<WebPartPages:DataFormParameter ParameterKey="ListName" PropertyName="ParameterValues" DefaultValue="{Name of your list}" Name="ListID"></WebPartPages:DataFormParameter>

And because now you can deploy it manually (because there is no more reference to the list ID (that is different in every site)