Tuesday, June 30, 2009

Document Library Icons Missing

Here’s something to keep in mind as you provision document libraries inside SharePoint.  You can provision document libraries through both the web (site) and site (site collection) scoped features.  The way you would do this is through use of the ListInstance element similar to the following:

<ListInstance
Id="Expenses" Title="Expenses" OnQuickLaunch="False" RootWebOnly="true"
FeatureId="00BFEA71-E717-4E80-AA17-D0C71B360101"
Description="Contains expense documents."
TemplateType="101" Url="Expenses">
</
ListInstance>

Unfortunately, when provisioning document library instances from site collection features the icons appear to be missing.  In the object model, which you can’t change after the fact, the ImageUrl property is empty.  If you look at the “View all site content” link, you’ll see what I’m talking about.


image_2_3B6F10A9.png (501×191)


This is just something to be aware of.  It may not be a show-stopper, but it’s an inconvenience to your users.  I’d recommend provisioning your lists as site features (at the Web scope).  It may mean more features to manage, however.

Thursday, June 11, 2009

Keep Site Definition IDs Unique

This recently bit me.  I had two different site definitions.  They had two different webtemp xml files, of course.

Here’s the first one:

<?xml version="1.0" encoding="utf-8" ?>

<Templates xmlns:ows="Microsoft SharePoint" >
  <Template Name="STORESITEDEF" ID="10010">

...

The second looked like this

<?xml version="1.0" encoding="utf-8" ?>

<Templates xmlns:ows="Microsoft SharePoint" >
  <Template Name="MARKETSITEDEF" ID="10010">

...

When I went to create my site, I kept getting this error:

The template you have chosen is invalid or cannot be found...

I incorrectly assumed that the ID was only relevant within a given site definition – why this wasn’t a GUID, I don’t know.  Anyway, I changed one of my IDs to be different and after an IISRESET all is well.

Tuesday, June 2, 2009

Always Capitalize (all-caps) Boolean Values in CAML

So here I was, late at night, banging my head against the desk trying to figure out why my a custom field’s custom property wasn’t hiding when I clearly stated Hidden=”true”.  As it turns out, you need to specify the uppercase value for that boolean or it simply won’t work.  There’s no error; it just doesn’t hide.  Here’s a snippet of code where this bit me while developing a custom column using the ProperySchema section to allow additional settings to be used for the field.

<FieldTypes>
<
FieldType>
<
Field Name="TypeName">CustomColumn</Field>
<
Field Name="ParentType">Note</Field>
<
Field Name="TypeDisplayName">My Custom Column</Field>
<
Field Name="TypeShortDescription">My Custom Column</Field>
<
Field Name="UserCreatable">TRUE</Field>
<
Field Name="ShowOnListCreate">TRUE</Field>
<
Field Name="ShowOnSurveyCreate">TRUE</Field>
<
Field Name="ShowOnDocumentLibraryCreate">TRUE</Field>
<
Field Name="ShowOnColumnTemplateCreate">FALSE</Field>
<
Field Name="FieldTypeClass">ACME.SharePoint.Blah.CustomField,
ACME.SharePoint.Columns, Version=1.0.0...</Field>
<PropertySchema>
<
Fields>
<
Field Name="MySetting"
Hidden="TRUE"
DisplayName="My Setting:"
MaxLength="500"
DisplaySize="40"
Type="Text">
<
Default></Default>
</
Field>
   ...

As you can see Hidden is set to “TRUE.”  “true” simply does not work.



What’s funny is that the WSS.XSD gives you intellisense in VS.NET (in most areas) for the following options for boolean fields: true, false, True, False, TRUE, FALSE.  Ok.  Why?


This was just one case where my choice of case caused an issue.  What about everywhere else?  So proceeded to tell my colleagues, including Bryan Phillips, about this oddity with hiding properties of custom fields.  He said that he always uses uppercase.  Not only for custom columns, but for everything.  I’ve typically used lowercase since it seemed to be close to my c# practices.  However, from now on, I’m going to capitalize my boolean values.