0

I have some code that creates a new Word document in a Document Set and then I want to set the Content Type to be a custom type inheriting from document that I have created.

var newLetter = item.Folder.Files.Add("filename.docx", memStr, true);
newLetter.Item["ContentTypeID"] = library.ContentTypes[FieldValues.ContentType.Letter].Id;

I am getting the following error:

Column 'ContentTypeID' does not exist. It may have been deleted by another user.

I'm doing the same thing with a TXT file in the same library and it works. Is there a way to fix this?

4
  • Is this using CSOM? Jan 23, 2015 at 21:14
  • @AmalHashim I don't think so, it is server object model (SPWeb, etc)
    – HamHamJ
    Jan 23, 2015 at 23:07
  • Can you try with newLetter.ListItemAllFields["ContentTypeID"] ... Jan 24, 2015 at 0:24
  • @Naim Didn't help.
    – HamHamJ
    Jan 26, 2015 at 14:51

1 Answer 1

0

I have resolved this by setting the content type at item creation by adding a properties Hashtable to my Add call, and setting the ContentTyeID in said properties.

I think there is still some underlying issue with not being able to change content types of documents that is also affecting the out of the box edit form.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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