Tuesday, November 15, 2011

How to add a survey list to the Quicklaunch

When you add a survey list to a site using a webtemplate or sitetemplate you add the following line to the onet.xml:

<Lists>
<List FeatureId="00bfea71-eb8a-40b1-80c7-506be7590102" Type="102" Title="$Resources:core,surveyList;" Url="$Resources:core,lists_Folder;/$Resources:core,surveyList;" QuickLaunchUrl="$Resources:core,lists_Folder;/$Resources:core,surveyList;/overview.aspx" />
</Lists>

When you create a site with this onet.xml the survey list is created however it’s not added to the quicklaunch. This is probably because the <Navbars> doesn’t contain a ‘Survey’ category.

To fix this add this line to the <Navbars> element:

<NavBar Name="$Resources:core,category_Surveys;" Prefix="&lt;table border='0' cellpadding='4' cellspacing='0'&gt;" Body="&lt;tr&gt;&lt;td&gt;&lt;table border='0' cellpadding='0' cellspacing='0'&gt;&lt;tr&gt;&lt;td&gt;&lt;img src='/_layouts/images/blank.gif' id='100' alt='' border='0'&gt;&amp;nbsp;&lt;/td&gt;&lt;td valign='top'&gt;&lt;a id='onetleftnavbar#LABEL_ID#' href='#URL#'&gt;#LABEL#&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;/td&gt;&lt;/tr&gt;" Suffix="&lt;/table&gt;" ID="1007" />

Or you could use one of the alternatives:
- Add the survey list in code (web.Lists.Add with SPListTemplateType.Survey) and set OnQuickLaunch to true.
- manually add the survey list to the quicklaunch using the List Settings –> Title, description and navigation. The Navbar item will be added automatically.

Wednesday, October 19, 2011

Deploy files to Pages subfolder (SharePoint 2010)


Scenario:
Deploy pages/files to a subfolder in the pages library.

How it’s done:
In Visual Studio 2010 create a module:

image

with the following elements.xml

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="AdminPages" Url="$Resources:osrvcore,List_Pages_UrlName;/AdminPages" Path="AdminPages">
<File Path="ChangePassword.aspx" Url="ChangePassword.aspx" Type="GhostableInLibrary" />
<File Path="ForgotPassword.aspx" Url="ForgotPassword.aspx" Type="GhostableInLibrary" />
</Module>
</Elements>

Some explanation about the elements file:
Module.Name: name of the module
Module.Url: location in SharePoint, where do you want to deploy the files to.
Module.Path: location of the files in your feature (In this case in VS2010 the ‘AdminPages’ module creates a directory in the feature with name ‘AdminPages’)
File.Path: location of the file in your feature (it also uses the Module.Path, so don’t add the ‘AdminPages’ because it’s defined in the Module.Path)
File.Url: filename in SharePoint (you could name the file whatever you like)
 
Add the module to a feature.
Deploy the solution.

After installing and activating the feature (that contains the AdminPages module) you will see that a folder ‘AdminPages’ is created in the /Pages (depending on language) folder.

image

image

Friday, June 24, 2011

Reminders for Continuous build for SharePoint projects in Team Foundation Server (TFS)

Based on this MSDN article How to Build SharePoint Projects with TFS Team Build I setup the build machine. When doing so and tested it on my current SharePoint 2010 project I found some issues. As a reminder-to-self here some notes:

Deployment of DLLs to GAC

Some dll’s should be deployed to GAC. Use gacutil (of the .NET 4 framework) to do this, using a .NET 2 or 3.5 version doesn’t work.

- Download and install the Microsoft Windows SDK for Windows 7 and .NET Framework 4
- Gacutil location for 64bit systems is C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\NETFX 4.0 Tools\

SharePoint DLLs

Copy all SharePoint dll’s from the C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI\
When your SharePoint project references Microsoft.SharePoint.Publishing, also copy System.Web.DataVisualization.dll (.NET 3.5). It location is C:\Program Files (x86)\Microsoft Chart Controls\Assemblies\ This is because the publishing assembly references the DataVisualization assembly.

Updating SharePoint 2010

When installing cumulative or Service Packs on SharePoint 2010, you need to update the dll’s on your build server to keep them aligned.

Thursday, June 23, 2011

SharePoint 2010 Workflow: Could not load file or assembly '$assemblyname$'

During workflow development I got the following error when starting a Site workflow:

Load Workflow Assembly: System.IO.FileNotFoundException:
Could not load file or assembly '$assemblyname$' or one of its dependencies. The system cannot find the file specified. File name: '$assemblyname$'


Very strange, it did worked for months. So I checked the workflow feature in the 14-hive. The element manifest was wrong. It contained the $assemblyname$ tag instead of the assembly name.

<Workflow
Name="Ctalk - MailCtalkEditieWF"
Description="Workflow for sending Ctalk Editions"
Id="15f3ae38-12bc-4dbf-ad2b-9281ff09d43e"
CodeBesideClass="Ctac.Ctalk.MailCtalkEditie.MailCtalkEditie"
CodeBesideAssembly="$assemblyname$">

After a ‘normal’ deployment in VS2010 the element manifest file was correct:

<Workflow
Name="Ctalk - MailCtalkEditieWF"
Description="Workflow for sending Ctalk Editions"
Id="15f3ae38-12bc-4dbf-ad2b-9281ff09d43e"
CodeBesideClass="Ctac.Ctalk.MailCtalkEditie.MailCtalkEditie"
CodeBesideAssembly="Ctac.Ctalk, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6a509658686505f0">


So what was the problem… It’s the VS2010 ‘Copy to SharePoint Root’ command part of the CKSDev extension. It just copied the file as is, it doesn’t replace the tag. So keep this in mind when using the ‘Copy to SharePoint Root’ command in combination with workflow development.

Wednesday, June 22, 2011

Provisioning URL values with description using element manifest

When provisioning files/items that contain an URL typed field you probably want to provide an url and description. When using an element manifest to provision some content you probably use something like this:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="Banners" Url="Banners">
<File Path="Banners\banner1.png" Url="banner1.png" Type="GhostableInLibrary">
<Property Name="URL" Type="string" Value="http://www.yellowred.nl"/>
<Property Name="NewWindow" Value="true"/>
</File>
</Module>
</Elements>
There’s no room for providing a description. The property element has the following ‘Type’ attribute options: int, string, datetime. So no url type.

As you know the URL value is just a string with in specific format: <url>, <description>
You can also find this format when using SharePoint Manager 2010. Open the item containing the url field. Check the schema.xml and search for the url.

To provide a description to the url, provision your data like this:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="Banners" Url="Banners">
<File Path="Banners\banner1.png" Url="banner1.png" Type="GhostableInLibrary">
<Property Name="URL" Type="string" Value="http://www.yellowred.nl, Yellow and Red"/>
<Property Name="NewWindow" Value="true"/>
</File>
</Module>
</Elements>