Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm trying to add content types into a library list, in order to make "Visible on New" option ticked.

Firstly I enabled contenttypes in the library, then I want to do this:

SPFolder rootFolder = list.RootFolder;
IList<SPContentType> ctList = rootFolder.ContentTypeOrder;
rootFolder.UniqueContentTypeOrder = ctList;
rootFolder.Update();

But this line IList<SPContentType> ctList = rootFolder.ContentTypeOrder; keeps throwing unexpected error:

Error occurred in deployment step 'Activate Features': 
Unhandled exception was thrown by the sandboxed code wrapper's Execute 
method in the partial trust app domain: An unexpected error has occurred.

I'm not sure if this error is related to the sandbox solution.

Related question: Content Types not visible under New Button

share|improve this question

1 Answer 1

up vote 3 down vote accepted

It's related to the sandbox, because you cannot use SPFolder.ContentTypeOrder and SPFolder.UniqueContentTypeOrder in sandbox :\

Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Available in Sandboxed Solutions: No

Edit:

If it's just to order, the code posted as an answer by James in this question might work.

share|improve this answer
    
Thanks! However I'm not ordering... I just want to enable the CT on New button –  wceo Jan 16 '13 at 9:17

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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