Tuesday 22 November 2011

Using the SharePoint date control in a web part

Here is a code sample of a web part that uses the sharepoint date control
The code is simple - three controls - a DateTimeControl from the Microsoft.SharePoint.WebControls namespace, a button and a text box.The button has a click event. On click, the event sets the text box to display the date that was selected in the DateTimeControl.


public class DatePickerWebPart : System.Web.UI.WebControls.WebParts.WebPart
{
DateTimeControl dtc;
TextBox t;
Button b;

protected override void CreateChildControls()
{
base.CreateChildControls();
dtc = new DateTimeControl();
dtc.ID = "dtc" + this.UniqueID;
this.Controls.Add(dtc);
b = new Button();
b.Text = "Click me to see the date";
this.Controls.Add(b);
b.Click += new EventHandler(b_Click);
t = new TextBox();
this.Controls.Add(t);
}

void b_Click(object sender, EventArgs e)
{
t.Text = dtc.SelectedDate.ToLongDateString();
}
}


Here is the result.

This is the web part when the page first loads

 
This is the web part when you click on the date picker

This is the web part when you click on the button


Tuesday 1 November 2011

Setting up Issue Tracking List

Tracking issues is a common task in companies. This may pertain to testing, product development, code promotion etc. SharePoint has a Issue Tracking list that can be used out of the box.
This article outlines the steps required to setup a Issue Tracking system.
·         Select Create from the ‘Site Actions’ menu
·         Select ‘Issue Tracking’ under ‘Tracking’ region (the Navigation may differ)
·         Enter a ‘Name’ and ‘Description’ for the list
·         Select ‘Yes’ to display in the Quick Launch region
·         Select ‘Yes’ to send e-mail notification. This is a good feature as the assignee of the issue gets e-mail notification
·         Click ‘Create’ button to complete
Add an Issue
You have a basic issue list with standard columns and views. Create additional columns and views as required (as explained later).
·         Click ‘New Item’ in the ‘New’ poplist to create a new issue item
·         Enter a ‘Title’ for the issue. For example, ‘Report’ fails with error
·         Select the employee or user to whom the issue is assigned to. If e-mail notification is enabled as explained earlier, this person would be notified of the issue creation and updates
·         Accept the default ‘Issue Status’ (normally ‘Active’ or ‘Open’)
·         Select the ‘Priority’ from the list
·         Enter a ‘Description’ for the Issue – this could be the nature of the issue and what caused it
·         Select a ‘Category’ from the list i.e. if you would like to track the issues by category
·         If there are ‘Related Issues’, select suitably
·         Enter a ‘Due Date’ i.e. the date by which the issue has to be resolved by
·         Click ‘OK’ to complete
·         To add a new item, follow the steps again
Adding Columns
You can add to these columns or delete irrelevant columns as required. For example, let us assume that an additional column is required to capture the ‘Environment’ the issue originated from. Steps are as follows:
·         Click Settings > List Settings
·         Click ‘Create Column’ under ‘Columns’ region – One can also ‘Add from existing columns’
·         Enter ‘Column Name’
·         Select a suitable information type for the column – In this example, ‘Choice’ is checked as we intent to select the appropriate environment from the choices given
·         Complete ‘Display Choices’, ‘Default Value’ sections
·         Click ‘OK’
Views
Apart from the default views, additional views can be created as well. There is no threaded or flat views in an issue list.
Printing Feature
The Issue Tracking list lacks a print view as well. However, the flexibility to export to spreadsheet and print is available; however, this involves additional formatting.
Status View
It is possible to report on Open, Closed, or Resolved items in the Issue Tracking list. This is an important requirement as one would like to know what issue are still outstanding at any time. Create a view named ‘open’ or ‘closed’ and apply suitable ‘filter’ criteria to accomplish this.