Save list as template – Include Content disabled: A solution

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

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

3 Responses to Save list as template – Include Content disabled: A solution

  1. Geetha says:

    Hi that was a nice article!! and it worked too.
    But i have a scenario where i need to include content of an existing issue tracking list.
    i want to get the content as it is in the new list created using the template.
    Any suggestions would be appreciated.

  2. Geetha says:

    Even i tried changing the issues.xml file, but for newly created lists alone it will work.
    Im having an existing issue tracking list which is in the root site, i want the same to be moved to its subsite, but with content. any other way to move the issue list along with the content?

  3. finarne says:

    Hi Geetha,
    If you don’t have access to the server then all I can suggest is you create a new issues list using the steps above then use the grid view to bulk copy and paste the items from the original list to the new list.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s