Thursday, 16 July 2009
Deleting unused SharePoint Content Types
It happens to every site collection admin at some stage. For whatever reason you're required to replace a defunct content type in your document library with a new one. Adding t he new one is easy. But then you try to delete the old one and receive the terrifically informative "Content Type is still in use" error.
You've tried everything:
- Updated any files you could find with the new content type.
- Checked every file twice to make sure you didn't miss any.
- Managed Checked Out files to locate all those tricky 'hidden' docs that haven't been checked in yet and only exist in some funky temp/draft state! (You'll either need to take ownership of these as site collection admin, or email a list to the original authors to get them to check them in or delete then. I can't believe there is no option to delete these en masse!)
- Run custom CAML queries to make REALLY sure you didn't miss any (using the fabulous U2U SahrePoint CAML Query feature - www.u2u.be/res/Software.aspx.
- Written a console app just to make ABSOLUTELY sure you didn't miss any.
- Emptied the recycling bin - both of them!
But still the error persists.
Just when I thought I'd exhausted all options it occurred to me that perhaps versions were the culprit. Looking at the version history for a few suspect documents confirmed that they were.
Running the following SQL query will find them all.
SELECT *
FROM AllUserData
WHERE (tp_DirName LIKE '%sitename/Shared Documents%')
AND ((tp_ContentType = 'myDodgyCT'))
ORDER BY tp_DirNameThis should be self-explanatory but tp_dirName is just using a relative path from the domain to the library. And ContentType is the explicit name of the content type to search on.
From there I just exported the results to Excel, filtered out duplicates and was left with a workable list of documents. Simply publish a final version of each (if required), then go to the Version History and delete all previous versions.
You could do all this in one step by turning off versioning for the library and then turning it on again. But this would delete versions for ALL documents. A good trick to remember when you're site quota is reached.
Good luck!
Labels: Content Types, MOSS 2007
Monday, 27 October 2008
Document Information Panel: A simple explanation
People seem to get so needlessly confused by this topic. I blame most of it on the lack of any reliable definitions.
Many articles discuss the use of InfoPath for this purpose - indeed even the option in the SharePoint UI for creating a custom template launches InfoPath! But unless your customisations extend to things that cannot be achieved OOTB it's actually so much simpler than that.
There are two fundamental pieces of information which can help explain all this and save you from a world of pain.
- Your customisations to the Document Information panel found in the big-3 Office apps are made in SharePoint - not the target application.
- The Document Information panel presented in documents created from a SharePoint library are nothing more than the fields defined in your content types (or an InfoPath form if you opted for this route).
If you're lucky enough to have InfoPath and feel like introducing more complexity then you can create a custom form to manage field validation and other advanced functionality.
For the rest of us, try the following:
- Add a custom column or two to one of your Document content types.
- Add the content type to a Document Library.
- Click the New tab to open a new document (Word by default) and view the Document Information Panel. (Office Button -> Prepare -> Properties. You can also set this to open automatically in your content type settings under Document Information Panel settings .)
You should see all your custom columns. Columns marked with a red asterisk (*) represent mandatory fields. Yes, it's that easy.
Labels: Content Types, MOSS, SharePoint
Wednesday, 22 October 2008
Document Libraries: which template?
This seems to be a topic that stumps even the most highly paid SharePoint experts but needn't. After all, the MOSS UI offers everything most enterprises would need, it's just a case of knowing where to look and exercising some not-so-common-sense.
Despite being called MOSS 2007, the base document content types actually use the old Office file formats. Confused? Yep, this is where most people get tripped up. The easiest way to replace these is to create a new document in each of Word, PowerPoint and Excel and upload them for each relevant content type under Advanced Settings -> Document Template.
This will provide you with a good base for any future content types that inherit from these.
DON'T save them as templates, as one might expect. Just as plain .docx, .pptx and .xlsx files. This is another common mistake.
These files will automatically get copied to the content type and every existing and new library to which it has been applied. If you're really curious you can verify this by looking in the hidden Forms folder within any library using the content type.
Labels: Content Types, MOSS, SharePoint
Subscribe to Posts [Atom]
