Clean up SharePoint's UI with jQuery

So, the case management system I’m working on has a ‘Mailbox’ library. Really, it’s just an email enabled document library, with the address set to the name of the case. Anyway, when emails are received into this list, we’d like to show the subject, sender, cc, to addresses, and so on. It turns out that email enabling a document library does in fact add columns for those properties (but they’re not automatically added to the default view).

mailbox-page-default

Neat! Until you start looking at the code itself – then it sucks… Continue reading “Clean up SharePoint's UI with jQuery”

Clean up SharePoint's UI with jQuery

Control the Content Types in the New menu via code

We’ve got a project with an interesting requirement for a Document Library. When the site it provisioned, it will have a number of documents already in it, of a specific content type. Users should not be able to create more documents of that content type. Further, we would be uploading documents via some custom screens which should also be stored as ‘hidden’ document content types.

No problem, I thought – in my Schema.xml for my custom Document library I can specify Hidden=”TRUE” in the ContentType node. Sadly, this doesn’t work entirely well… Continue reading “Control the Content Types in the New menu via code”

Control the Content Types in the New menu via code

No Thumbnails for Custom Picture Library Definition

I’ve got a Custom Picture Library definition – it encapsulates much of the same functionality I described a few days ago for Document Libraries. I built it, then ran Solution Generator against it to create the List definition and schema.

It all seemed to work alright, but when I tried uploading an image, it didn’t create my thumbnails, or the _w and _t folders the thumbnails are hidden in! This was a problem.

Well, I cracked open reflector (how did we do .NET development before it?) and dug around. Didn’t find much, except that the Upload.aspx page decides if it is for a Picture Library based on the List Template‘s Type attribute (ordinarily 109).

The Type attribute of a List Template tag says this:

Provides a unique identifier for the template. This identifier must be unique within the feature, but need not be unique across all feature definitions or site definitions.

This attribute corresponds to the Type attribute of the List element

Hmm. Interesting. I had changed my List Template‘s Type – I’ve been keeping all of mine unique in my solution, as I do have multiple lists based on the same out-of-box type (e.g. multiple lists based upon the ‘Custom List’ type). As I was suspicious, I changed this back to 109, and tried again. My thumbnails now worked.

I guess that this mean that the thumbnailing done during the upload process is contingent on the list’s Type being 109 still. As a consequence, I guess that a feature can only have one custom Picture Library definition (as “This identifier must be unique within the feature”).

No Thumbnails for Custom Picture Library Definition

Simplified People and Groups pages in SharePoint

One of my pet peeves with SharePoint is the People and Groups pages. These are pretty damn complicated.

standard-perms-page

You typically get groups for:

  • Owners
  • Members
  • Visitors

And often you can have

  • Approvers
  • Moderators
  • Designers
  • Individual users granted rights directly on the site (rather than being in a group)

… and so on. And if individual sites start to break from inheritance and define their own groups, you get even more groups. It’s possible (especially if the administrator of the system doesn’t understand what they’re doing – which is often the case) to end up with 3 times as many groups as sites!

Frankly, this is enough to confuse me, never mind users. Trips into the People and Groups pages often takes me some time to understand what I’m seeing. And the worst part is that often users just want to be able ‘Give Fred access to this site’. They don’t care about other groups or other sites, permissions levels, or any of that jazz.

The case management system we’re working on at the moment has this sort of requirement. Each case is a site, and we want ‘Case Owners‘ to be able to add/remove ‘Case Owners‘ or ‘Case Workers‘. They don’t need access to other groups. They don’t need the ability to send emails, call people, remove users from the site collection, or any of the other (confusing) options on the menus. So, I built my own administration pages… Continue reading “Simplified People and Groups pages in SharePoint”

Simplified People and Groups pages in SharePoint

Show Site, List or Item information on Pages

I’ve seen a few questions on Twitter over the last few weeks about how to show properties from Sites or Publishing pages within pages. Actually, this is very easy.

Obviously, if you’re working with Publishing Pages, you’ve got all your publishing controls, which you can see in SharePoint Designer…

publishing-controls-in-SharePoint-Designer

But what about site information, such as the Site Title? Or other Page Information, such as the Last Modified time? Well, I want to introduce 4 other controls – ProjectProperty, ListProperty, ListItemProperty and FieldValue Continue reading “Show Site, List or Item information on Pages”

Show Site, List or Item information on Pages

Use jQuery to populate and hide fields in an EditForm.aspx

We’ve got an interesting requirement. We’re using a SharePoint list to store documents which are related to K2 SmartObjects. One of my colleagues is building a custom user control that’s going to show information from this SmartObjects, and associated documents. We want to allow users to

  • click to add a document to our smart object entity
  • upload a file to a library
  • fill in some details
  • automatically associate that file by a GUID

Sounds complicated? Actually, it’s not so hard! Continue reading “Use jQuery to populate and hide fields in an EditForm.aspx”

Use jQuery to populate and hide fields in an EditForm.aspx

The Summary Toolbar in a ListView Web Part

Yesterday I was describing adding a ListView Web Part pointing at a specific view. I had a ListView Web Part which showed the right columns, but also showed the full toolbar:

case-comments-listview-2

…and I had a ListView which showed the Summary Toolbar, but didn’t show the right columns:

case-comments-listview-1

The Web Parts are defined identically, except for the BaseViewID property. So, what gives? Continue reading “The Summary Toolbar in a ListView Web Part”

The Summary Toolbar in a ListView Web Part

Pointing the ListViewWebPart at a particular view

So yesterday I described adding a ListViewWebPart to a Site Definition. This works – but how do you point the web part at a particular view?

This took a little figuring out. My ListViews were being defined in my ONET.xml file as:

<View List="Comments" BaseViewID="0" WebPartZoneId="Left">

Clearly the BaseViewID was a likely candidate – but what did it point to, and how could I define a view for my ListView? As is stood, My ListView kept appearing as:

case-comments-listview-1

Well, BaseViewID isn’t well documented, but it is actually the ID number of a view in the List Definition. I can’t say that I was able to see how to define a view for out ListView within our Site Definition itself.

If we open up our List Definition’s schema.xml file we see:

case-comments-list-definition-views

You can see that each of the views is assigned assigned a BaseViewID. I tried changing my BaseViewID to ‘1’ and my web part’s view changed to:

case-comments-listview-2

Great! This show’s the extra column I wanted – but it also shows the toolbar, which I didn’t. I really wanted the Summary Toolbar (the ‘Add new Item’ link, as in the top screenshot), but I’ll describe how I got that tomorrow.

Pointing the ListViewWebPart at a particular view

Pointing ListViewWebParts at lists

I was creating a site definition recently, and I wanted to use a ListView web part in it. List View Web Parts are a little strange; unlike other web parts they’re represented by a ‘View’ element inside the ‘File’ element for a page; it’s sort of saying that we want a view onto a list shown on this page. Looking at the out-of-box site definitions, they show things like:

<View List="104" BaseViewID="0" WebPartZoneID="Left" />

Here the ‘List’ attribute is the ‘Type’ id of the List, as defined in the list definition. Great – but what if (as in my case) you have two separate lists of the same type?

Well, it turns out that it also accepts a relative URL too. As the documentation says…

List – Optional Integer or Text. Specifies the type of list. This value can be either the ID of the template for a list (an integer), or the URL to a list provisioned in the site (a string). Best practice is to use Text, because Integer might not be specific enough (e.g., if there are two announcements lists in the site and you specify List=104).

So we can use:

<View List="Comments" BaseViewID="0" WebPartZoneID="Left" WebPartOrder="1" />

Here the ‘List’ attribute is set to ‘Comments’, which is the URL to my ‘Comments’ list (no, it isn’t the name – ‘cos this list’s display name is ‘Case Comments’). And this works nicely. This is actually how some of the out-of-box site defintions work, but most of them refer to their lists by type.

Pointing ListViewWebParts at lists

List Definitions don't need their own forms…

List definitions don’t need their own forms – if you’re happy with the out of box ones. Mostly, if you use something like the solution generator to create your List definition, it will create a number of forms by default for you:

as-created-by-solution-generator

These are then deployed into your list:

when-deployed-as-seen-in-sharepoint-designer

However, you don’t actually need these in your definition, unless you’re providing your own custom forms! Continue reading “List Definitions don't need their own forms…”

List Definitions don't need their own forms…