Tuesday, December 14, 2010

Change View headers in SharePoint 2010

For changing the view Headers you need the SharePoint 2010 Designer.

To start modifying your view select the “Edit List in SharePoint Designer” or simply open the designer and navigate to your list

SNAGHTML1ee2bedd

Click on the placeholder that has the View Web part to enable the ribbon tools.

SNAGHTML1ee7bfb8

Click List View Tools –> Design, and Choose Customize XSLT – Customize Entire View,  to enable editing of the xslt.

SNAGHTML1ee9f394

Click on a header, and replace the xslt in the codeview. The default xslt will be <xsl:value-of select="$fieldtitle"/> replace with something like <xsl:text disable-output-escaping="yes">Your new header</xsl:text>

Now for the important part:

You must remove all ddwrt:ghost="hide" attributes in your view. If these attributes exists the view will not be correctly saved. Do a search replace and save the “file”.

Before:

SNAGHTML1ee50b29

After:

SNAGHTML1ef12b85

Thursday, November 25, 2010

Edit initial text in TFS WorkItem User Story

The popular “As a <type of user> I want <some goal> so that <some reason>” is always the initial text in a user story work item.

When a WorkItem is opened in VS2010 the editor switches to a custom editor (<Witd:WITD application="Work item type editor")

The safe way is to use this editor

The value is not defined as the default value for the Description field. It is defined in the workflow for the workitem.

Start by choosing the Workflow tab

WIT_Workflow

Double click on the first transition (The one to the left)

Choose the fields tab and double click on the System.Description

WIT_Transition

Select the Rules tab, and double click on the DEFAULT entry

SNAGHTML35e1cc4

Edit your initial text

SNAGHTML3614dd3

You can also edit the XML file outside a the custom editor

It can easily be changed by taking a look in the XML (as XML not WIT in Visual Studio 2010) The text is located at line 177 in the XML file.

Friday, November 12, 2010

Custom List Form with version history

When turning on version history on a list that is using custom list forms the text entered in a multiple line textbox is not displayed. when the field is in Display mode. The text just seems to be lost in the database. But by examining the version history for the item you will see all the changes.

The solution is simple:

In order to display the history use another control type, use the <SharePoint:AppendOnlyHistory/> instead of <SharePoint:FormField/>

By using this control you will get a nice list of all the field versions.

And by combining the two you can get a field that displays the history, and at the same time give the possibilities to edit the text:

TFS_Bug_with_history_full

Tuesday, November 9, 2010

Cannot reference …WorkItemTracking.Controls

When developing custom WorkItem Control Types you must reference Microsoft.TeamFoundation.WorkItemTracking.Controls But the filtered list of assemblies does not display the assembly despite the fact that it is in the GAC (C:\Windows\Assembly)

There are multiple ways of retrieving the correct reference, one is to use the Muse.VSExtensions.

This extensions lists all assemblies in the GAC and allows you to add an assembly as a reference

Add_GAC_Reference

Tuesday, November 2, 2010

IsDlg=1 numeric value is not validated

When using SP.UI.ModalDialog.showModalDialog(…) you should set the parameter IsDlg to 1 when calling a List Form (View/Edit/Create) this removes all references to masterpage items such as quick launch etc.

Keep in mind that the numeric value entered after the IsDlg has no effect, so setting IsDlg=0 is the same as IsDlg=1 SharePoint only checks for the existence of the variable IsDlg and does not check if the value is set to anything. So leave out the IsDlg entirely when the page is loaded without popup windows

Thursday, September 30, 2010

disable-output-escaping="yes" on People or Group Column

When creating a custom List Form from SharePoint Designer 2010 the People or Group field/columns ends up being displayed as HTML code instead of the field value

PID

To get fieldtypes that renders as HTML to display correctly just add the parameter disable-output-escaping="yes" to the value-of select:

EscapeYes

This will display the People or Group field with the correct link to the person.

Friday, July 30, 2010

Error when connecting VS2008 to TFS2010

When connecting Visual Studio 2008 to TFS2010 you must have the following update installed “Visual Studio Team System 2008 Forward Compatibility Update for Team Foundation Server 2010 interoperability

If you are using “Local Database Cache functionality in Smart
Device projects” the “Microsoft Synchronization Services for ADO.NET 1.0 for Devices” must also be installed.

The Visual Studio 2008 SP1 is a required prerequisite to install the above updates.

After installing you must use the complete Url to the TFS2010 Server, and leave out the trailing slash. if the URL contans a trailing slash a message “Unable to switch servers at this time. Team Explorer is busy.” will appear several times. And end in a dialog box  with the message “Error in the application”

Add 2010 Server with 2008 Client

For more information about the limitations of a 2008 client with a 2010 server see “Compatible Matrix for 2010 RTM Team Foundation Server to Team Explorer 2008 and 2005

Wednesday, July 28, 2010

Connecting to TFS2010 from a Webpart

With the implementation of Team Foundation Server 2010 the need for some integration with SharePoint 2010 was needed. Just to test the TFS API a simple webpart for registration of User Stories from SharePoint was created.

New to the TFS API I discovered that connection to the Project Collection needed a ICredentialsProvider (Fallback).  The UICredentialsProvider works fine in Windows Applications but when using the web, this provider can not be used…

The first step is to create a new Interface that uses the NetworkCredential class to return the credentials

public class NetworkCredentialsProvider : ICredentialsProvider
    {
        private readonly NetworkCredential credentials;
        public NetworkCredentialsProvider(NetworkCredential credentials)
        {
            this.credentials = credentials;
        }
        public ICredentials GetCredentials(Uri uri, ICredentials failedCredentials)
        {
            return this.credentials;
        }
        public void NotifyCredentialsAuthenticated(Uri uri)
        {
        }
    }

Use this Provider to connect to the Project Collection

ICredentialsProvider TFSProxyCredentials;
var credentials = new NetworkCredential("Username", "Password", "Domain"); TFSProxyCredentials = new NetworkCredentialsProvider(credentials);

var projectCollection = TfsTeamProjectCollectionFactory.GetTeamProjectCollection(projectCollectionUri, TFSProxyCredentials);

When running this code from a webpage/webpart the TFS will return an exception: “TF237121: Cannot complete the operation. An unexpected error occurred.”

This Exception is occurs because the TFS Client does not have a reference to a local Cache for storing files. (Normally this is stored in the current user profile area)

The solution is to let the TFS Client know where to store cache-files. This is done by defining a application setting named WorkItemTrackingCacheRoot and specifying a local path on the server (With proper NTFS rights)

The application setting can be created in web.config or programmatically

web.config:

<appSettings> <!-- Add reference to TFS Client Cache -->
   <
add key="WorkItemTrackingCacheRoot" value="C:\TFSClientCache"
/> </appSettings>

Code:

if (WebConfigurationManager.AppSettings["WorkItemTrackingCacheRoot"] == null || WebConfigurationManager.AppSettings["WorkItemTrackingCacheRoot"] == String.Empty)
{
   WebConfigurationManager.AppSettings["WorkItemTrackingCacheRoot"] = System.IO.Path.GetTempPath() + "TFSClientCache";
}

Thanks to Naren’s blog for pointing out the Client Cache settings

Click to download complete code to connect, and to get project info

 

Friday, April 30, 2010

Get the value of PeoplePicker during postback

Using the People Picker Field in a custom listform is basically straight forward. But I ran into a little problem when I needed to extend the validation of the form based on the user specified in the field:

ResolvedEntities[] vs. Entities[]

I needed to run a CAML Query and use the username as a parameter but the property Entities did not contain any objects during postback.

Solution use the ResolvedEntities instead, this contains the users that have been validated and is persistent during postback…

if (Pe_EffectiveUser.ResolvedEntities.Count != 0)
{

PickerEntity PEffectiveUser = (PickerEntity)Pe_EffectiveUser.ResolvedEntities[0];
//PickerEntity PEffectiveUser = (PickerEntity)Pe_EffectiveUser.Entities[0];
this.EffectiveUser = PEffectiveUser.Description;

String UserID = this.EffectiveUser.Substring(this.EffectiveUser.IndexOf("\\") + 1);
}
else
{
// Show a button to validate before continuing
}