Thursday, January 20, 2011

Convert ListItem ID to UniqueID

This is just one way of getting from the ListItem ID (Not Index) to the GUID UniqueID

In SharePoint 2010 you can use SPList.GetItemByIdSelectedFields(…) or SPList.GetItemByIdAllFields(…)

Example:

GetItemByIdSelectedFields(Int32.Parse(this.ListItemID), new string[] { "UniqueId" });

If you don’t have 2010 you can always retrieve the ListItem with a CAML Query…

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.