For some reason when I read those first words I throw my hands up and think of the movie Highlander

Yet another pain in the arse error message I hit…[Microsoft.SharePoint.SPException] = {"There can only be one instance of this list type in a web.\n\nAn instance already exists."}

Awhile back when doing some custom list development, I recalled that you could set property to basically say that one and only one instance of your custom list type could exist within a site (Unique=”True”).  See Below for what I am talking about. 

<ListTemplate Name="MyNetworkMembershipList" DisplayName="My 
Network Membership List Template" Type="100" Description="Template 
for My Network Membership Lists" BaseType="0" 
OnQuickLaunch="True" SecurityBits="14" Sequence="410" 
Image="/_layouts/images/itgen.gif" Unique="True" 
DisableAttachments="True" Hidden="False" HiddenList="False" 
FeatureId="{GUID}" />

 

Apparently with blog sites you can’t have both content approval and versioning turned on for a Post list.  Of course the client wanted both turned on, so I turned to writing an event receiver to handle the add/update/delete events so that I could basically create a “version” list that would live behind the scenes for legal purposes.

I started out by writing the event receiver to handle the added/updated/deleted events and to basically take the Post listitem and “copy” a version of it to my version posts list…easy enough.  I then obviously had to add code in my feature event receiver to create the versioned post list if it was already created.  I tried to do the following:

Guid newListId = web.Lists.Add("BlogPostVersioningList", "Blog Posting Version 
List", SPListTemplateType.Post);

Turns out that the list type “Post” is one of those lists in a blog site that is set to be Unique.  I deceided to take a look at the blog site definition and see if I could verify this.  I dug into the 12 Hiv, 12\TEMPLATE\SiteTemplates\Blog\Xml  and opened “onet.xml”.  A few lines down I noticed this line:

 

<ListTemplate 
Name="posts" 
EnableModeration="True" 
DisplayName="$Resources:core,posts_schema_blg_title;" 
Type="301" 
BaseType="0" 
OnQuickLaunch="TRUE" 
FolderCreation="FALSE" 
AllowDeletion="FALSE" 
Unique="TRUE" 
DisallowContentTypes="TRUE" 
SecurityBits="11" 
Description="$Resources:core,posts_schema_blg_description" 
Image="/_layouts/images/itposts.gif"></ListTemplate>

BOOM! Tough Acting Tenactin! As you can see above, “Unique=’TRUE’”, hence the error message I got.

So..now that I know I can have only 1 list of type Post….what the hell am I supposed to do?  Since the columns in the Post list were information that I wanted to keep, I decided to basically create a generic list and then “synch” up the fields between the Post list and my new generic list, resulting in a version list that I could then move my posts to from the SPItemEventReceiver

 
Guid newListId = web.Lists.Add("BlogPostVersioningList", "Blog Posting 
Version List", SPListTemplateType.GenericList);

 

At the end of the day, I now have a feature that creates a “Versioned” Post list and attaches an Item event receiver to move blog posts on add/update/delete over to my “Versioned” Post list for legal purposes.


Posted in:   Tags:

Comments


May 21. 2009 20:31
kitchenaid
Oh man, nice posting. This coding will be so useful to me. Thanks for sharing.

http://kitchen-aid-part.blogspot.com/http://kitchen-aid-part.blogspot.com/


January 16. 2010 02:18
SEO Mumbai
Thanks for sharing this in so much detail..

http://www.onketing.com/http://www.onketing.com/


January 25. 2010 07:18
no fax loans
When placed in command - take charge.

http://cashusloans.com/http://cashusloans.com/


February 1. 2010 08:08
Loans in CT
He who laughs, lasts.

http://superpaydayloan.com/state/Connecticuthttp://superpaydayloan.com/state/Connecticut


February 8. 2010 05:28
loans
Do not be in a hurry to succeed. What would you have to live for afterwards? Better make the horizon your goal; it will always be ahead of you.

http://cashusloans.com/loans.htmlhttp://cashusloans.com/loans.html


February 9. 2010 02:55
payday loans
Learning is the beginning of wealth. Learning is the beginning of health. Learning is the beginning of spirituality. Searching and learning is where the miracle process all begins.

http://fastloansus.com/http://fastloansus.com/


February 14. 2010 11:57
Cameras Photography
I think it is ok if there is two instances but I do not know that much about templates for blogengine

http://www.camerasphotography.com/http://www.camerasphotography.com/

Search Blog

Blog Roll

    OPMLDownload OPML file

    Recent Comments

    Banners

    Theme Grabber
    Disclaimer
    The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

    © Copyright 2012 Tony Testa's World