I am trying to add a new Content Type to a document library (Full trust solution). It works fine just adding it to an existing site, but when I try to create a Sub-Site I get a "Save Conflict" and the sub-site provision fails.

The error states: "Provisioning did not succeed. Details: Failed to create the 'Workflow Tasks' library. OriginalException: Save Conflict."

I don't understand why its referring to Workflow Tasks.

Here is the code (Item added Event) that I use. Any ideas?

    Public Overrides Sub ListAdded(properties As SPListEventProperties)
    'Get References to Site, Web, List and Content Type
    Dim thisSite As SPSite = properties.Web.Site
    Dim thisWeb As SPWeb = properties.Web
    Dim thisList As SPList = properties.List
    Dim thisContentType As String = "My Custom Document"

    'Get the List that has been Added
    Dim targetList As SPList = properties.List

    'Get the List Type (List Template ID)
    Dim listType As SPListTemplateType
    listType = targetList.BaseTemplate

    '101 = If a Document Library
    AddContentTypeToList(thisSite, thisWeb, thisList, thisContentType)
    SetDefaultContentTypeToList(thisWeb, thisList, thisContentType)
    'SetColumnRequiredToList(thisWeb, thisList, "Title", thisContentType, True)
End Sub

Private Shared Sub AddContentTypeToList(ByVal web As SPWeb, ByVal list As SPList, ByVal ctName As String)
        web.AllowUnsafeUpdates = True

        list.ContentTypesEnabled = True

        Dim ContentType As SPContentType = web.AvailableContentTypes(ctName)
        ' Remove Existing Default Content Type (Image)

        web.AllowUnsafeUpdates = False
    Catch ex As Exception
        'Write to the SharePoint ULS Log
        Microsoft.Office.Server.Diagnostics.PortalLog.LogString("An Exception Occurred on Carmeuse.SP.ER.SetDocumentContentType - AddContentTypeToList: {0} || {1}", ex.Message, ex.StackTrace)
    End Try
End Sub

Regards, Bismarck


I resolved it by adding the Template ID in the elements.xml file.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.