Deleting work item in TFS using Visual Studio 2010

As I was setting up TFS (Team Foundation Services) for my upcoming SharePoint project, I created few work items such as Tasks, Sprint Backlog, Bugs etc. also created custom fields and values within them. To test these items, I created a few test work items before moving it to live. Now, I wanted to get rid of the test work items I created before I could log live data in it. So here comes this post, where I would write on how we can delete work items from TFS. So, first of all, there is no simple tick and delete UI from Microsoft which does so. Microsoft recommends using command line to delete the work items. There are some free tools available through few of the sites, but I prefer deleting using command line. Follow the steps below:
  • Open Visual Studio Command Prompt by navigating to Start > All Programs > Microsoft Visual Studio 2010 > Visual Studio Tools
  • Note down the IDs of the work items you want to remove from the TFS
  • Within the command prompt type the below syntax:
witadmin destroywi /collection /id:,,

Note: For noting down the IDs of the work items you can run a query that has ‘test’ in the Title field, provided you have entered test while your testing.


Retrieving SharePoint List Items using Javascript in a Custom Webpart

So you want to fetch list items but do not want any post back, yes we can implement that using Javascript within our custom webpart by using a client control. 

Let me explain that in a step by step process
  • Create a new Visual Webart Project in VS 2012.
  • Give it a proper name and make it a Farm level solution.
  • Now delete the existing Visual WebPart item within the solution (to remove the default name) and add a new item – Visual WebPart and give it the desired name.
  • Open ascx file and copy paste the code below


function fetchListItems()
var clientContext = new SP.ClientContext.get_current();
var oList = clientContext.get_web().get_lists().getByTitle('List Name');
//I am fetching the list items randomly from the first 30 items
var randomNumber = Math.floor((Math.random() * 30) + 1);
var camlQuery = new SP.CamlQuery();

//increase the number within the RowLimit tag to fetch the number of items you wish
camlQuery.set_viewXml('' +
'' + randomNumber + '1');
this.collListItem = oList.getItems(camlQuery);


clientContext.executeQueryAsync(Function.createDelegate(this, this.onQuerySucceeded), Function.createDelegate(this, this.onQueryFailed));


function onQuerySucceeded(sender, args) {

var listItemInfo = '';
var listItemEnumerator = collListItem.getEnumerator();

while (listItemEnumerator.moveNext()) {
var oListItem = listItemEnumerator.get_current();
listItemInfo += '\nID: ' + oListItem.get_id() +
'\nTitle: ' + oListItem.get_item('Title') +
'\nBody: ' + oListItem.get_item('Body');

function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() + '\n' + args.get_stackTrace());

Here I am using client control and not any server control so there will not be any post back experience.
If you wish you can add more functionality to this same webpart and use it in your real world scenario like adding server controls to it and then writing some code behind for it and so on.