Tuesday, March 17, 2009

Customise SharePoint List forms – Part 2

In Part 1, I walkthrough modifying the display form of the list by adding headers. This was achieved using SharePoint Designer.  This is easy to do on development machine but how would you do this on Test or Production environment. You would not be able to connect to this environment using a developer tool. If you are in your organization, please avoid as this is not good practice. Opening pages using SharePoint designer would un-ghost your custom pages (add to database). If you install the changed pages using SharePoint solution, your application would read from database and not from file system.

To deploy a custom dispform to the production environment, you need to create a WSP package.

Steps:

1.      Create List Instance Schema:

The best tool which REALLY does a job is Imtech StsAdm Commands. Download it from http://www.codeplex.com/imtech/Release/ProjectReleases.aspx?ReleaseId=10875

2.      Install Imtech STSAdm package to your development server

3.      The command sytax is

stsadm.exe -o ocdexportlist

           -url <url of the site containing the list>

           -name <list name>

           -dir <export location>

 

This action exports the definition of a list with the given Name

Example:

stsadm.exe -o ocdexportlist -url http://sharepoint –name Employee -dir C:\EmployeeList\

 

 

4.      Run the command changing the text in red according to your environment

5.      This would generate following files –

 

Schema.xml

The XML which describes the list instance

DispForm.aspx

Display form based on the List

NewForm.aspx

New form based on the List

EditForm.aspx

Edit form based on the List

AllItems.aspx

Form which displays the default view(All Items)

 

6.      Create Elements.xml and Feature.xml files(Check Microsoft site for creating them).They are simple XML file which contains the feature information

7.      Create a SharePoint Package and add the files to the project

8.      Build the solution and deploy on production site. You should now have a list called Employee and having headers in Display form for the item.

 

2 comments:

Armin said...

can this be uses in sharepoint 2010? I have a error when execute command:
Value cannot be null.
Parameter name: type

Sanjay Sansanwal said...

I had not tested this with SharePoint 2010. Anyway, as per me this will not work as SharePoint 2010 uses 14 Hive and not 12 Hive.