none
Hide content types from "content type" dropdown RRS feed

  • Question

  • We have libraries that have multiple content types.
    When a user uploads a doc they select the relevant content type from the list... all normal.

    However, we have a couple of content types that do not apply for upload, only add new.
    For example we have a content type of link which allows the user to create a new link in the library and this link points to a doc in another library.

    Obviously you cannot upload a link to a library so it makes no sense to have this option avavilable.
    How do I remove options from this dropdown?

    Wednesday, February 19, 2014 3:49 AM

Answers

  • Finally got there!
    ok as suspected it was in use so I had to trawl through the recycle bins and the files with no checked in version to hunt down the test doc which used this CT. I was then able to delete the CT from the library.
    I added the CT back to the library but kept it hidden.
    I went to the doc set settings and moved the CT over to the allowed CT types for doc sets.

    Now when I upload a doc the offensive CT is not the default CT in the list (its at the foot - still nonsensical in this scenario but far enough out the way to not cause trouble). I am also able to use this CT from the "new" button when within the doc set. But not at the library level which is what we want.

    • Proposed as answer by thriggle Thursday, February 20, 2014 3:45 PM
    • Marked as answer by Pratik VyasModerator Friday, February 28, 2014 7:25 AM
    Thursday, February 20, 2014 12:39 AM

All replies

  • Hi QPR_JAY,
    To hide content types from drop down follow below steps

    >> Go to list / library settings
    >> Click on "Change new button order and default content type" under content type
    >> Uncheck the box besides content type which you don't want to display

    Let us know if this helps, thanks

    Regards,
    Pratik Vyas | SharePoint Consultant | http://sharepointpratik.blogspot.com
    Posting is provided AS IS with no warranties, and confers no rights
    Please remember to click Mark As Answer if a post solves your problem or Vote As Helpful if it was useful.

    Wednesday, February 19, 2014 10:20 AM
    Moderator
  • Hi,

    You need to change the Form View for "Adding New" using InfoPath Forms or SPD to ommit the unwanted content types to be displayed on "Add New".


    Murugesa Pandian.,MCTS|App.Development|Configure


    Wednesday, February 19, 2014 11:03 AM
  • Pratik, I am not trying to remove a content type from the "add new" button, I need to remove the option from the dropdown in the upload.aspx form
    Wednesday, February 19, 2014 7:39 PM
  • Not sure if this the same suggestion as from Pratik but if so then both tools you mention would be wrong.
    To remove a content type from the "add new" option you untick it from the default content types under library settings. To do it on multiple libraries you use powershell.

    However, this is *not* what I am trying to do.

    When a user uploads (not creates new) a document to a library they are presented with the metadata form to fill out properties. When a library has more than one content type then one of these properties is "content type" which is a drop down list featuring the various content types associted with the library.

    I need to remove one of these option from this drop down list (only)

    Wednesday, February 19, 2014 7:43 PM
  • If you mean I need to edit editform.aspx in sharepoint designer to omit the content type... When I open the page in SPD I just see the placeholder formlistpart with sample controls in there - not my actual controls.
    • Edited by QPR_JAY Wednesday, February 19, 2014 7:49 PM
    Wednesday, February 19, 2014 7:45 PM
  • Hi QPR_JAY,

    There's no good way to hide valid content types from the form without doing some kind of hack.

    Fortunately, I have a hack in mind.

    In a text file, save the following text:

    <script>
    var ctselect = document.querySelector("[Title='Content Type']");
    if(ctselect != null){
    ctselect.options.removeChild(ctselect.options[0]);
    }
    </script>
    This will remove the first content type from the drop-down. To remove a different one, change the zero to another number in "ctselect.options.removeChild(ctselect.options[0]);"

    Upload that text file to a document library to which all uploaders have at least Read access.

    Go to the Edit properties page for a document in that library. Right-click and choose "Properties", then copy the URL and paste it into the address bar of a new tab or window. Since it's no longer in a dialog box, remove the "&isDlg=1" parameter from the URL to make it show up correctly in its own window. Anyway, you should now be able to click Site Actions -> Edit Page

    Add a Content Editor Web Part to the page, edit its properties, and in the Content Link property paste the path to the text file you uploaded. Make sure the content editor web part is below the list form web part.

    Note that this doesn't get around people changing the content type in the Document Information Panel that can be accessed from an Office document.



    • Proposed as answer by thriggle Wednesday, February 19, 2014 9:58 PM
    • Unproposed as answer by thriggle Wednesday, February 19, 2014 9:58 PM
    • Edited by thriggle Wednesday, February 19, 2014 9:59 PM
    Wednesday, February 19, 2014 9:58 PM
  • Thanks, ordinarily this is the sort of JS I would consider, unfortunately we are talking hundreds of doc libraries.

    We had a content type (doc link) that was added to a library but it remained hidden while we discussed "stuff", this library was saved as a template and then used to template out tons of libraries.

    Then the decision was made to use this content type, so (using powershell) I unhid this content type for all relevant libraries.

    What I didn't realise was that a consequence of this would be a new properties drop down list asking for a content type to be chosen. This list never appeared before and my guess is that all the other CTs inherited from document and therefore had the same metadata requirements, Doc link has different ones (e.g. a URL field) so now, in order for SP to know which fields to display within edititem.aspx it must first know which content type we are dealing with... hence the new drop down list.

    Point is that doc link will never be a valid CT for uploading a document (only adding new) so not only is it superfluous but, in same cases, it is the top choice in some libraries which is confusing users and resulting in calls to the help desk asking what is this url field!?

    Wednesday, February 19, 2014 10:09 PM
  • Yeesh, that is a pickle.

    Not as good as hiding it entirely, but you could write a Powershell script to change the content type order on the affected libraries so that the Link to a Document content type isn't the first from the top. That might be an ugly script, though, especially if these libraries have each been customized with additional content types since being created.

    Wednesday, February 19, 2014 10:24 PM
  • More info I meant to add!

    When the PS script was run, the doc link CT was specifically slotted in at the end of the list, with document being the default. This is perfect everywhere... except where doc sets come into play.

    On some libraries we only allow a CT of doc set. Users must upload/create a document inside of a document set as opposed to the root of the library. So just the one CT typoe for the library. However the doc set itself allows all the others within in.

    Normally for a library you go to CTs and you set the default and visibility etc however I can't see where to do this for the document set. I see where you add CTs by selecting on the left and adding to the right and that would be greate except that my Document Link does not show in that list. Yet it is in the content type drop down.

    Curious, I added it to the list of CTs and when I go back to the library I get the error that there is a duplicate CT of document link!

    Wednesday, February 19, 2014 10:30 PM
  • Setting the default types on multiple libraries is easy in PowerShell, my blog seems to be dead at the moment (it was working 30 minutes ago, shouldn't have gone with GoDaddy) but i think i've got something on there.

    Document sets are a pain, the way to set the default content type on them is to add the content types to the library in sequence. The first you add will be the default CT.

    IF you've already added all the CTs then you'll need to remove them, save the changes and publish them if relevant, then re-add them again. Simply removing and re-adding on the same page without saving will fail.

    This can be modified using PowerShell but its' a monster, the only instructions i could find were C# that needed to be translated and i don't think i ever got around to publishing those.

    Wednesday, February 19, 2014 10:49 PM
  • Thanks, and yep I unhid this CT and at the same time set another as the default for all libraries and that is working perfectly, everywhere except from within a document set.

    Rather than the default selection being document, it is Doc Link.
    So I go to document set settings in order to set the default and doc link is not listed under "Content types allowed in the Document Set:" it is listed under "Available Site Content Types:" though.

    Why it is not shown I have no idea? If I add it I get the error duplicate content type. I cannot remove it to re-add it as it is not there. I'm not dreaming or drinking, I've checked 5 times. It's in the drop down list in edititem.aspx but not shown in "Content types allowed in the Document Set:"

    Wednesday, February 19, 2014 10:55 PM
  • If you're doing this right then the document set is a site content type, possibly even pushed down from a hub.

    Check the document set content type on the library itself and see if it isn't added there.

    Wednesday, February 19, 2014 11:02 PM
  • It sounds like there's some discrepency between what content types are hooked up in the underlying object model and what the document set interface knows about. If the Link to a Document content type was added via powershell, you might need to remove it the same way and then re-add it through the document set interface.

    Do you have a lot of libraries with document sets where this needs to happen? If it's only a handful, removing the content type with powershell and then adding it back manually might be feasible.

    Wednesday, February 19, 2014 11:15 PM
  • You are probably right. I can see the content type under library settings (hidden as we only allow doc sets to be created at the root) but I cannot remove it from the library as it says it is in use. By the doc set is my guess.

    I can't remove it via sharepoint manager either.

    I'll try powershell and report back

    Wednesday, February 19, 2014 11:43 PM
  • There is a deliberate option to have a content type vary on lists/libraries from a site content type or between libraries. This is achieved by creating local copies of every content type that is used in that library. It confuses most people to start with but it's a good thing (honest). If you've enabled content types on the library (which you have) then you can view the library version of the content type, which will most probably include the extra column. Can you confirm?

    It's also possible for document sets to become disconnected from their templates, Document sets aren't like nearly every other item in SharePoint in that they inherit from folder rather than item. Somewhere along the way the process they use can fail. The main way this can be seen is that existing document sets don't always get updated by changes. It's rare but i've seen it happen a few times.

    You don't want to remove the content type from the libraries (to do so would require deletion of EVERY document set that uses that template including from the recycle bin).


    Thursday, February 20, 2014 12:33 AM
  • Finally got there!
    ok as suspected it was in use so I had to trawl through the recycle bins and the files with no checked in version to hunt down the test doc which used this CT. I was then able to delete the CT from the library.
    I added the CT back to the library but kept it hidden.
    I went to the doc set settings and moved the CT over to the allowed CT types for doc sets.

    Now when I upload a doc the offensive CT is not the default CT in the list (its at the foot - still nonsensical in this scenario but far enough out the way to not cause trouble). I am also able to use this CT from the "new" button when within the doc set. But not at the library level which is what we want.

    • Proposed as answer by thriggle Thursday, February 20, 2014 3:45 PM
    • Marked as answer by Pratik VyasModerator Friday, February 28, 2014 7:25 AM
    Thursday, February 20, 2014 12:39 AM
  • Nice! I'm glad you were able to work around the problem. Thanks for sharing your solution, too.
    Thursday, February 20, 2014 3:45 PM