1

I am creating a custom list and in that trying to add an existing content type.

Below is the code used:

testList.ContentTypesEnabled = true;

SPContentType testContentType = web.ContentTypes["TestContent"];
if (testContentType != null)
{
    testList.ContentTypes.Add(testContentType);
    testList.Update();
}

I am getting the below error:

{System.ArgumentException: 0x80070057 at Microsoft.SharePoint.Library.SPRequestInternalClass.AddField(String bstrUrl, String bstrListName, String bstrSchemaXml, Int32 grfAdd)

I have the site collection Admin permission. The content type exists in the site. The content type is attached to another list also.

How to fix this?

BTW, I get this same error adding it through the UI also.

************* CONTENT TYPE XML ********************

I think something is wrong with my content type definition. I exported this using powershell.

ContentType ID="0x0101001CC4D99118BEC246AB8D5DF12A34B61F" Name="Volunteer" Group="Smile" Version="0"><Folder TargetName="_cts/Volunteer Documents" /><Fields><Field ID="{c042a256-787d-4a6f-8a8a-cf6ab767f12d}" Name="ContentType" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="ContentType" Group="_Hidden" Type="Computed" DisplayName="Content Type" Sealed="TRUE" Sortable="FALSE" RenderXMLUsingPattern="TRUE" PITarget="MicrosoftWindowsSharePointServices" PIAttribute="ContentTypeID" Customization=""><FieldRefs><FieldRef ID="{03e45e84-1992-4d42-9116-26f756012634}" Name="ContentTypeId" /></FieldRefs><DisplayPattern><MapToContentType><Column Name="ContentTypeId" /></MapToContentType></DisplayPattern></Field><Field ID="{5f47e085-2150-41dc-b661-442f3027f552}" Name="SelectFilename" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="SelectFilename" Group="_Hidden" ReadOnly="TRUE" Type="Computed" DisplayName="Select" Hidden="TRUE" CanToggleHidden="TRUE" Filterable="FALSE" AuthoringInfo="(web part connection)" HeaderImage="blank.gif" Sortable="FALSE" Customization=""><FieldRefs><FieldRef ID="{1d22ea11-1e32-424e-89ab-9fedbadb6ce1}" Name="ID" /></FieldRefs><DisplayPattern><IfEqual><Expr1><GetVar Name="SelectedID" /></Expr1><Expr2><Column Name="ID" /></Expr2><Then><HTML><![CDATA[<img align="absmiddle" style="cursor: hand" src="/_layouts/15/images/rbsel.gif?rev=23" alt="]]></HTML><HTML>Selected</HTML><HTML><![CDATA[">]]></HTML></Then><Else><HTML><![CDATA[<a href="javascript:SelectField(']]></HTML><GetVar Name="View" /><HTML><![CDATA[',']]></HTML><ScriptQuote NotAddingQuote="TRUE"><Column Name="ID" /></ScriptQuote><HTML><![CDATA[');return false;" onclick="javascript:SelectField(']]></HTML><GetVar Name="View" /><HTML><![CDATA[',']]></HTML><ScriptQuote NotAddingQuote="TRUE"><Column Name="ID" /></ScriptQuote><HTML><![CDATA[');return false;" target="_self">]]></HTML><HTML><![CDATA[<img border="0" align="absmiddle" style="cursor: hand" src="/_layouts/15/images/rbunsel.gif?rev=23"  alt="]]></HTML><HTML>Normal</HTML><HTML><![CDATA[">]]></HTML><HTML><![CDATA[</a>]]></HTML></Else></IfEqual></DisplayPattern></Field><Field ID="{8553196d-ec8d-4564-9861-3dbe931050c8}" Name="FileLeafRef" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="FileLeafRef" Group="_Hidden" ShowInFileDlg="FALSE" ShowInVersionHistory="FALSE" Type="File" DisplayName="Name" AuthoringInfo="(for use in forms)" List="Docs" FieldRef="ID" ShowField="LeafName" JoinColName="DoclibRowId" JoinRowOrdinal="0" JoinType="INNER" Required="TRUE" Customization="" /><Field ID="{8c06beca-0777-48f7-91c7-6da68bc07b69}" Name="Created" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Created" Group="_Hidden" ColName="tp_Created" RowOrdinal="0" ReadOnly="TRUE" Type="DateTime" DisplayName="Created" StorageTZ="TRUE" Hidden="TRUE" Customization="" /><Field ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" Name="Title" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Title" Group="_Hidden" Type="Text" DisplayName="Title" Required="FALSE" FromBaseType="TRUE" Customization="" ShowInNewForm="FALSE" ShowInEditForm="TRUE" /><Field ID="{28cf69c5-fa48-462a-b5cd-27b6f9d2bd5f}" Name="Modified" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Modified" Group="_Hidden" ColName="tp_Modified" RowOrdinal="0" ReadOnly="TRUE" Type="DateTime" DisplayName="Modified" StorageTZ="TRUE" Hidden="TRUE" Customization="" /><Field ID="{822c78e3-1ea9-4943-b449-57863ad33ca9}" Name="Modified_x0020_By" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Modified_x0020_By" Group="_Hidden" ReadOnly="TRUE" Hidden="FALSE" Type="Text" DisplayName="Document Modified By" Customization="" /><Field ID="{4dd7e525-8d6b-4cb4-9d3e-44ee25f973eb}" Name="Created_x0020_By" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="Created_x0020_By" Group="_Hidden" ReadOnly="TRUE" Hidden="FALSE" Type="Text" DisplayName="Document Created By" Customization=""></Field></Fields><XmlDocuments><XmlDocument NamespaceURI="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms"><FormTemplates xmlns="http://schemas.microsoft.com/sharepoint/v3/contenttype/forms"><Display>DocumentLibraryForm</Display><Edit>DocumentLibraryForm</Edit><New>DocumentLibraryForm</New></FormTemplates></XmlDocument></XmlDocuments></ContentType>
1

It seems like an issue with your Content Type. Check fields and make sure none of them has Indexing enabled.

http://www.entwicklungsgedanken.de/2008/07/20/cannot-complete-this-action-error-when-adding-a-contenttype-to-a-list/

  • I think you are right. My content type has no fields. I will post the content type xml – Kyle Johnson May 22 '15 at 17:22

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.