first off: big fan of this site and have always found a solution to a problem when visiting here.
I have a small problem when using the Client Object Model for Sharepoint 2010:
I am trying to set the Content Type of an item, however it keeps reverting back to it's original ContentTypeId
after I call the "Context.ExecuteQuery()
".
Here is a sample of the code:
item["ContentTypeId"] = targetContentType.Id.ToString(); item.Update(); destinationContext.ExecuteQuery();
If I step through the code and check the ContentTypeId
I can that it has changed but as soon as I hit ExecuteQuery
it reverts back to the original Content Type.
The item in question sits in a sub-folder of the document library and is a docx
file. The Content Type itself does exist. If I run the same code on any other file type, e.g: htm
; it changes the content type successfully.