Category Archives: Content Types

Gooey SharePoint Scripting

You may also be interested in: ViewPoint for SharePoint


Editor’s note: Contributor Alex Brassington is a SharePoint consultant working for Trinity Expert Systems. Follow him @brassingtonalex

Today i’m going to show you how to script Sharepoint through the GUI. Whilst in this example we’ll be running the code on server the same concepts and approach can be used to Script it from any machine that can hit the relevant website…

Our example might seem to be a little forced but it’s based on a real world experience. We had a client who had a fairly complicated Content Type scenario, over 150 Content Types spread over 8 levels of inheritance with untold columns. Then we discovered an issue and needed to publish every single one of those content types. This is the classic example of where PowerShell should be used but awkwardly they’d been burnt with PowerShell publishing before.

As such we had a flat edict, no PowerShell publishing of content types. It must go through the GUI.

A post i’d seen recently by Dr James McCaffrey popped into my head. It was about using PowerShell to automate testing of web applications using PowerShell.
Why not use the same process to automate the publishing of the content types?

The first thing to do is to get ourselves an IE window:

$ie = New-Object -com &q0uot;Internet Explorer" 
#This starts by default in a hidden mode so let's show it 
$ie.Visible = $true

This isn’t much use on its’ own so let’s send it to a page. In our case we want to go to the page to publish one of our content types. We know that the publish page itself is an application page that is referenced from a site collection root web with the following URL syntax:


Glossing over how to get the ContentTypeID for now we have this:

$pageUrl= "http://sharepoint/sites/cthub/_layouts/managectpublishing.aspx?ctype=0x0100A4CF347707AC054EA9C3735EBDAC1A7C"

Now PowerShell moves fast, so we’ll need to wait for Javascript to catch up.

While ($ie.ReadyState -ne 4) 
    Sleep -Milliseconds 100 

Now we’re there, let’s get the publish button. Thankfully this button has a consistent ID that we can get using the trusty F12 button in IE.

Identifying an element’s ID uwing F12

The catchily titled “ctl00_PlaceHolderMain_ctl00_RptControls_okButton” button? Depressingly i think i’m starting to see the naming convention behind these ids…

$textBoxID = "ctl00_PlaceHolderMain_ctl00_RptControls_okButton"
#You have to pass the Document into it's own object otherwise it will fail 
$document = $ie.Document 
$button= $document.getElementByID($buttonID)

And now all we need to do is to click that button:


Now you might think that we’ve done all we need to do here and slap it into a foreach loop and be done with it. Of course you can’t do that as you need to give IE time to send that request using our good old friend Javascript.

So we wait for the page to re-direct us:

While ($ie.locationurl -eq $url) 
start-sleep -Milliseconds 100 

Now we can slap it into a foreach loop and with a little bit of work we can come up with something like the code below:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ea SilentlyContinue 
#URL for the content type hub to use 
$CTHubURL= "https://sharepoint/sites/cthub"
#Get the Content Type hub 
$site = Get-SPSite $CTHubURL
#Content Types to publish 
$ContentAndColumns = @( 
("Document Type 1"), 
("Document Type 2"), 
("Document Type 3") 
#Open a new IE window 
$ie = New-Object -com "InternetExplorer.Application"
#Make the window visible 
$ie.visible = $true
#Loop through the content types and publish them 
foreach ($contentTypeName in $ContentTypes) 
    Write-Verbose  "Processing $ContentTypeName"
    #Content types live at the root web 
    $web = $site.rootWeb 
    #Get the content type using it's name 
    $ct =   $web.ContentTypes[$ContentTypeName] 
    #Get the GUID for the CT 
    $GUID = $ct.ID.ToString() 
    #Get the URL for the page based on the content type hub url, the application page that does publishing and the GUID 
    $url = $CTHubURL+ "/_layouts/managectpublishing.aspx?ctype=" + $GUID  
    #Go to the page 
    #Wait for the page to finish loading 
    while ($ie.ReadyState -ne 4) 
        start-sleep -Milliseconds 100 
     #The ID of the button to press 
    $buttonID = "ctl00_PlaceHolderMain_ctl00_RptControls_okButton"
    $document = $ie.Document 
    $btn = $document.getElementByID($buttonID) 
    #Push the button 
    #Wait for the page to be re-directed 
     while ($ie.locationurl -eq $url) 
        start-sleep -Milliseconds 100 
     Write-Verbose "Content Type $contentTypeName published"

I don’t know about you but there is something deeply neat about sitting at your desk watching IE do the dull task that you were convinced was going to bring your RSI back with a vengance, and in half the time you could do it.

This example might not be useful for that many people but the concept is intriguing. There’s no reason most of this can’t be done without any code on the server at all, the only time we use it is to get the GUIDs and those can be pre-fetched if needs be. Nor does it need any significant rights, as long as the account you use has permision to get into that site collection and publish content types then that’s all they need.

The logical destination of this is Office 365, the scripts and rules for running them on there are limited and limiting, they have to be. But the beauty of Scripting is that we don’t have to be limited by the detail of code, we can use higher level components and tools to worry about that for us. In this case, the GUI that microsoft were kind enough to provide us for when it’s too awkward to find the PowerShell console.

SharePoint: Get the business to own the content types

You may also be interested in: SharePoint-based solutions by B&R Business Solutions


Editor’s note: Contributor Ben Henderson is Manager of Sevices at Colligo Networks. Follow him @ben3003

On a recent engagement we were tasked with building out a content model that would satisfy departments involved in the first phase of a SharePoint implementation.

The primary aim of the process was fourfold:

  1. Brief candidates from all departments through an information sheet asking them to consider the types of documents they use on a day-to-day basis.
  2. Assess their knowledge and ability through follow up interviews.
  3. Provide an example of what we are looking for.
  4. Provide them with a starting point to work from in order to build up the content model.

I am not saying that this is the perfect solution but I believe that there is a fine balance between handholding, and leaving them to sink or swim. This approach seemed to fit right in the middle of that and worked well with the strategy of the business.

Why did we take this approach really? It was basically because we felt we needed the business to own the content model.

If we had created it for them then there would have been adoption issues, push back, and inaccuracy in the information within the content model. But the issue with getting the business to own the content model is that they need to understand what a content model is. Something even IT Pro’s struggle to understand.

I have seen issues with the understanding of content types. The business likes to define content types as file types (doc, pdf, xls, jpg) and there is a big knowledge jump needed to go from there to full understanding of the concept.

One technique that we used with great effect is asking them to bring some files that they have stored and would say they were “business documents”.

An example of this was Invoice_for_Enron_Oct_2012_Final_Signed.pdf and gave us a great starting point to begin to explain how content types are built up.

Explaining that the content type is Invoice, and the other bits of information are properties that pertain to the invoice that was a great start to the conversation.

Perhaps try it with the documents you have saved on your desktop? Or do you use other simple techniques to share with the community?

How to Create a Calendar Overlay Using Custom Content Types in SharePoint 2010

You may also be interested in: SharePoint-based solutions by B&R Business Solutions


Editor’s note: Contributor Adam Quinn is a Senior Information Architect at the American College of Physician Executives. Follow him @lucidpiper

I recently was tasked with creating a new SharePoint Calendar to capture a variety of different events for my organization. They wanted to visually see differences in a calendar view, so I opted to use the Calendar Overlay option (using SharePoint 2010), and create multiple content types for each of the different types of events since many events had to capture unique information.

As I journeyed down what seemed a fairly straightforward path, I encountered a variety of roadblocks to which I had difficulty finding the answers including having duplicate titles for each event in calendar view. This prompted me to write this post on how to successfully set up a single Calendar that uses different content types and have them display using the calendar overlay function. This is mostly an OOB approach which optionally requires use of SharePoint Designer 2010.

First and foremost, I documented what my content types were going to be. I established what base metadata was required across all events, and made a “Base Event” type based on the OOB Event content type. I also added a couple of custom site columns to use in these content types.

As a side note, I initially went down the path of using an “Item” as my base content type instead of an “Event”, mainly because the Event CT includes the “Workspace” option; I was unable to find a way to hide that field from users (something we did not want to use) – however after further investigation I discovered how to easily hide this field using SharePoint Designer (see Appendix below). If you do want to use this field, use of SPD is not required.

Once I had my base event type defined, I used an Excel spreadsheet to document the fields and map out additional Content Types using my “Base Event” CT as the parent:


Working with my stakeholders, I used this core content type to start the conversation and then defined what additional fields were required for the other CTs. At the end of this exercise, I documented 7 custom content types to use in this calendar using the format above. This provided a great reference when I was actually creating the new content types and greatly helped to confirm with my stakeholders that we’re capturing the correct information.

I then used my worksheet as a map to create the Content Types:

Site Actions->Site Settings->Site Content Types->Create

Give each CT a unique name and description. For my Base Event I used the Event as the Parent Content Type. For all other custom content types, I used my Base Event as the Parent Content Type:


Once all the content types are configured, create your new Events Calendar:

Site Actions->More Options->Create Calendar

Go into the List Settings to add the new content types and configure views:

Calendar Tools->Calendar->List Settings

Under Content Types, select Add from existing site content types. From here you can add multiple content types to include in your calendar:


By default, the calendar uses the Event content type, which I did not need as I had created my own custom Event CT. To remove this after adding your new CTs, you can delete the OOB default from this calendar by clicking on the Event CT in List Settings, and selecting Delete this content type. You can also use the Change new button order and default content type to establish your new default and configure the order your content types will display to your users.

Create Custom Calendar Views

Now that your content types have been added, you’ll need to create a custom calendar view for each content type that you want to have displayed in the calendar overlay.
Scroll to the bottom of the List Settings page and select Create View->Calendar View

Provide a unique name that maps the view to one of your content types (i.e. Webinar Calendar). The Audience should be set to Public View. You will also want to make sure each calendar view for each content type mirrors each other using the same settings (example below):


You then need to provide the filter criteria to only show this content type (example):


Once finished, click OK to save the view. Go through this same process to create a new Calendar view for each of your content types.

After all of your views have been configured, you can now apply these views to display as a calendar overlay. Exit the List Settings and go into the base Calendar View (the view that was created by default when you created your calendar). In the left column, click on Calendars in View:


Select New Calendar to add as an overlay (Note – you will want to enter the overlays in the order you want them to be displayed on the main calendar page – these cannot be re-ordered once created). Name this calendar the same as your view (i.e. Webinars). Select a color to represent this calendar in the main overlay. Then enter the URL of the site where your list lives (not the list itself), and click Resolve. This will populate the drop-down fields with available lists and views based on the site listed in the Web URL field. Select your appropriate List and View:


Repeat this process for each calendar view you want to have rolled up in the main calendar overlay, giving each Calendar a unique color. Once completed, you are ready to start entering data in the calendar – however, as you’ll notice with this configuration, this will likely create double-entries in the calendar overlay. This can be easily remedied by placing a filter on your primary Calendar view:

Go to your main Calendar View. You’ll notice now under “Calendars in this view” all the additional calendars that have been added. Note that clicking on these calendars will filter the calendar to just show that particular view for end users:


From the main view dropdown (or under Calendar Tools) select Modify this View. Make sure the criteria defined in this view matches what you’ve defined in the custom calendar views. Under Filter, you want to set the following criteria to weed out the duplicate entries:


Yes, leave that field blank. As this calendar uses only content types you’ve defined, this will remove the duplicate entry issue. Save the view, and now you should be good to go!


Appendix: How to hide the Workspace option from Event content types using SharePoint Designer:

So you’ve got your custom content types defined for various events, but you don’t want your users to be able to create a new workspace site for every event they create. In fact, you just don’t want that option at all! This is easy to remedy, but requires SharePoint Designer to do so.

From any view in your calendar, select List Toole->List in the top toolbar. In the Customize List section, select the Edit List function:


This will open up your list in SharePoint designer (may take several seconds). Once it loads, your content types will be listed in the bottom box of the left column:


Click on the name of one of the content types you want to remove the Workspace column from (i.e. Webinar). In the Customization box, select Edit content type columns. This will display a list of all the columns included in your content type and note what is required, optional and probably include several Hidden fields. Find Workspace under Column Name and select it to highlight the row (notice that Property value = Optional). Click on Optional once while the row is highlighted to trigger the dropdown selection, and select Hidden. Make any other changes you require, and then X out of the main window, which will prompt you to save your changes.

Use the Navigation (far left column) to drive back to your Calendar (under Lists and Libraries) and repeat for all other content types that you want to hide this field from. When finished, you’ll find when your users select a content type to add to your calendar, this option is no longer visible.

I hope you find this information helpful!

Webinar: Understanding SharePoint Content Types


Editor’s note: Contributor Benjamin Niaulin is a SharePoint Specialist at Sharegate. Follow him @bniaulin

In a continued effort to help new SharePoint users adopt the platform, I began a Webinar series on Understanding SharePoint a few weeks ago.  My first online session for this series covered the basics of a site. You can still find a recording of “Understanding the SharePoint Basics” if you missed it.

This online session will cover SharePoint Content Types. I know, the word seems complex and it feels only the SharePoint Experts are using it. But it doesn’t have to be complicated.

Session information:

Date: Wednesday February 13th at 1:30pm Eastern Time

The purpose of this session is for Power/Super Users to get familiar with Content Types in their site. Really understand what they are and how to leverage them when creating Collaboration sites or even Publishing Sites. One of the examples we will cover is how to manage “Invoices” throughout your Site Collection easily.

What is a Content Type?
An introduction to the concept of SharePoint Content Types in Sites and Site Collections.

Creating a Content Type
See how we can create a Content Type properly, using the SharePoint interface

Using Content Types
Associate a Content Type to list and libraries in your Site Collection

Understand existing Content Types all over your Site
Microsoft has already created many for SharePoint. We will look at the ones you have been using and how you can leverage them.

I will also give some time for questions at the end, the goal of this online session is for everyone to properly understand what Content Types are and how to use them.

I hope you will join me on Wednesday February 13th 2013 at 1:30pm (Eastern Time) for this online session.
Register to save your seat.

Recording of “Understanding what’s in a SharePoint Site” webinar and some thoughts


Editor’s note: Contributor Benjamin Niaulin is a SharePoint Specialist at Sharegate. Follow him @bniaulin

To my surprise, the SharePoint Webinar I organized on “Understanding what’s in a SharePoint Site” got a lot of traction. Many comments on Mark Miller’s post about the SharePoint community were related around the fact that everyone has become so knowledgeable or technical that we tend to forget people are still starting with SharePoint. I took the ball and decided to do a Webinar that would cover the basics of what is in a site and really focus on understanding everything.


Based on the feedback and questions even after the webinar, I realized there is still a very strong need for information to be available for Power Users / End User. But it’s not just because of the Webinar, the many SharePoint Saturdays I have been attending has shown me the very same thing. Where it hit me, was at SharePoint Saturday Ottawa a few weeks back. I was presenting on the Content Query Web Part, very Power User in my opinion. Well, I was in the “Developer” track. And I thought about it, editing the itemstyle with XSLT and exporting the Web Part to change commonviewfields…. Hmm yeah I guess it’s very advanced, perhaps considered developing for many. But, I have been doing this for so long that I considered it “basic” and didn’t understand at first why I was in that track. That’s what happens to many I think, we tell ourselves “Well I won’t write about that, I did it for SharePoint 2007 already” or “Everyone knows what a Site Column is, I’ll assume they do and continue”. Fact is, many do not. It’s important to continue providing a source of information for everyone and not forget the Power Users and End Users.
I will try to make these kind of Webinars available more often – based on “Understanding the SharePoint basics” and make it always available so everyone can participate.

Here is the video recording:

Presentation available:

Thank you

Again, thank you to everyone that participated and took the time to fill out the survey at the end. The feedback was amazing and it helps me want to do many more like these. Some key takeaways was that there might have been too much information squeezed into such a short time and not enough time for Q&A. I will take that into consideration for the next one.

Feel free to leave suggestions for next topics, what would you like to see covered?

Leave a comment below.

SharePoint Content Type Hub: Inconvenient Updates

You may also be interested in: O’Reilly - SharePoint 2010 at Work


Editor’s note: Contributor Octavie van Haaften is a SharePoint consultant for Mavention. Follow him @eivatco

Recently, I had to develop some kind of tool for a customer that would manage their content types from the content type hub. This tool included content migration as well. Think of renaming a content type or changing the parent of a content type. During development I noticed that updating a content type and republishing it from the content type hub, it did not update the content type all the way to the sub-sites and lists. In spite of what the option says in the Managed Metadata Service Connection properties dialog:


The Test

Let’s take a test drive. In my example I have the following content type set to a document library and I will rename the content type. Let’s see what the results are.



The My Content Type in the library is inherited from the site content type My Content Type. The latter one has been published from the content type hub. And by design, all published content types are readonly.


I renamed the content type My Content Type to My Renamed Content Type in the hub, republished it, started all necessary timer jobs and went back to my document library.


So, the site content type is updated, but not the library one.

For us developers, this seems like a SPContentType.Update() and not a SPContentType.Update(true).

The quest

But let’s take a deep dive into the code. I use ILSpy, but Reflector will do too. The update is performed by the Content Type Subscriber timer job. After some searching and digging it all starts with the assembly Microsoft.SharePoint.Taxonomy and the namespace Microsoft.SharePoint.Taxonomy.ContentTypeSync.Internal. Starting from SubscriberTimerJobDefinition jumping to SubscriberImport and you will see the SynchronizeSite method. Some interesting lines of code are:

In both methods you will see, at some point, the following lines of code:

No Update(true) at all.

This leaves us writing our own update mechanism to sub-sites and lists. But that’s for another blog post.

SharePoint Error “The content type is in use” Explained

You may also be interested in: Secure SharePoint with User Claims White Paper from Titus


Editor’s note: Contributor Octavie van Haaften is a SharePoint consultant for Mavention. Follow him @eivatco

Recently I developed a tool to manage content types from a content type hub. Think about renaming content types or changing the parent. Something that doesn’t work out of the box. At least not completely. (I will blog about this later, hold on)

While developing and testing, I encountered the error The content type is in use.


There are several situations that will cause this error.

  1. Content exists in the Recycle Bin
    Marc D Anderson wrote a blog post about this recently. You’ll have to delete the content from the Recycle Bin somehow.
  2. Documents not checked in yet
    Try this: you have a Document Library with your content type as default and check-out/check-in is required. Then you upload multiple documents. After the upload the items are still checked out and you are the only one that can see them. As of this moment your content type cannot be deleted. Everything needs to be checked in and modify the content type for each item.
  3. Previous minor version exists
    Try this: you have a Document Library with Minor/Major versioning enabled. Upload a document and give it your content type. Publish your document to version 1.0. Then edit the properties and give it another content type. This will be 1.1. As of this moment your content type cannot be deleted. You’ll need to publish it first to the next major version.

So you have checked everything? No content using the content type, Recycle Bins are empty etc..? Sure? Well, I can tell you that you still might not be able to delete the content type. Trying so will get you this error message:


Some lovely SharePoint solution (WSP) with a feature deployed the content type. And to protect the solution and it’s functionality the content type cannot be deleted.

Now you have it. When deleting a content type fails you now know why.

SharePoint 2010: How to Create Document Sets

You may also be interested in: Buy 1 Training Get 1 Free with Innovative-e


Editor’s note: Contributor Alexandru Dionisie is an Internet Professional and Technical Writer. Follow him @tutorialeoffice

 - Document Sets were introduced in SharePoint 2010 and provide a broad range of capabilities to manage content. They allow the grouping of related content into a single entity. The content that is contained within a Document Set can be treated as an atomic unit or as part of a larger set of documents that can be treated consistently.

In SharePoint 2010 you can create your own custom content type.

A document set can contain documents, workbooks, presentations or videos.

How is it done?

  • Go to Site Actions – Site Settings - from Site Collection Administration section click on Site collection features;
  • Activate the Document Sets feature;
  • Go back to Site Settings – from the Galleries section click on Site content types;
  • Click on Create;
  • Add a Name and a Description;
  • We need to select Parent Content Type from Document Set Content Types;
  • For the Parent Content Type we have Document Set;
  • Create a new group: HR

  • Click on the OK button.

In the Site Content Type Information page click on Document Set settings.

In the Available Site Content Types we will add Video.

By default, the Document content type is added.

Now, in the Default Content we have to add our content.

To save the settings click on the OK button.

Now we have to set this content type as default for the desired document library.

  • Go to the Home page;
  • Click in the Shared Documents web part;
  • Click on the Library tab – Library Settings;
  • Click on Advanced Settings;
  • Add a check mark on Yes to allow users to be able to manage content types;
  • Click on the OK button.

In the Content Types section click on Document content type.

Click on Delete this content type optionOK.

In the settings page click on Add from existing site content types.

In the Available Site Content Types choose CV for HR and the click on the Add button.

Click on the OK button to save the settings.

Go back to the Shared Documents library – click on the Documents tab from the ribbon – NewCV for HR – add a Name and a Description.

The final result looks like this:

In the below image we can see:

  • a Image Web Part;
  • a Document Set Properties Web Part;
  • a Document Set Contents Web Part.