So today I was putting together a simple SharePoint 2007 site to manage the testing of an application I’m developing. The users of the app have no real experience in proper testing so I thought I’d help them out by creating a custom issues list that they could use to manage the list of test steps they had to carry out.
My goal was to create the custom list, populate the list with the series of test steps and then save the list as a template including the content. For each round of testing we’d then create an instance of this new list and the testers would execute each of the steps. Seemed simple enough.
I created and populated the list (removing some of the default issues list columns and adding a bunch of custom columns, irrelevant to this discussion), then I went to good old List Settings and clicked Save list as template, filled out the File name, Template name and Template description fields and was then about to select the Include Content check box when I noticed that the check box was disabled.
Hmmmmm.
After some searching I found that an Issues List does not allow content to be saved when saving as a template, I wanted to use an Issues List as I wanted the Send email when ownership is assigned setting to be available.
More searching turned up the DontSaveInTemplate attribute of the List element in a list schema. (note that this also turned up the EmailAssignTo attribute which is apparently how the Issues List email setting works).
So here’s what I did to resolve this issue:
1. Save the list as a template without including the content.
2. Browsed to the List Template Gallery.
3. Downloaded the list template I saved in step 1.
4. Cracked open the .stp file using 7-Zip (of course).
5. Opened the manifest.xml file.
6. Navigated to the ListTemplate/UserLists/List element
7. Changed the DontSaveInTemplate=”TRUE” attribute to DontSaveInTemplate=”FALSE” (leaving the lovely EmailAssignTo=”TRUE” well and truly alone)
8. Saved the manifest.xml file
So, now I had a manifest.xml file containing a list template which in theory should allow me to create a list instance from, *then* be able to save a template from this new list instance which *will* allow me to Include Content. My next task was to get the manifest.xml file packaged back up into a .stp (.cab) file.
Now creating .cab files can be a PITA but on this occasion it was pretty simple. My SharePoint development machine has Visual Studio 2008 Professional installed (obviously) and as a result I had a copy of MakeCab.exe in the “C:\Program Files\Microsoft Visual Studio 9.0\SmartDevices\SDK\SDKTools” folder.
I copied the manifest.xml file to the aforementioned folder, fired up a command prompt, navigated to the folder and ran the following command:
MakeCab manifest.xml TestScriptTemplate.stp
Now I had a nice, shiny template that I could use to create a list, populate the list with the default set of test scripts *then* save this new list as a template which I could then use to create the test script issues list for each round of testing.
Thinking about this made me realise that there are lots of occasions where you might want to grab a list template, crack it open, make a few small changes and then package it back up and upload the template back to the site. There’s been several times where I know that I could make a list view filter work using nested AND and OR conditions if I wrote the CAML filter by hand.
Using this method of downloading the template, cracking open the manifest.xml, doing a quick edit then packaging it back up again will let me just get on with the job without having to resort to building a .wsp and asking the awfully nice server administrator if they’d be so kind as to install my custom .wsp.
YMMV
Colin