How To Access Work-Item(s) From Team Foundation Server 2018

Gravelsoft
4 min readJul 1, 2021

At the point when you have various groups and each group creates loads of code as a feature of their expectations, dealing with the code with no appropriate apparatus is a difficult assignment particularly in a light-footed venture the board cycle. Monitoring every form is an overwhelming undertaking in such situations. There is a shot at everything can go haywire right from forming, coordination, till definite conveyance.

With Team Foundation Server (TFS) you can say farewell to all problems. TFS is a top Microsoft item for overseeing source code. With TFS (5 fundamental records are free) you can oversee projects for both cascade and coordinated styles. Prerequisite administration, computerized assembles, testing and delivery the executives capacities, and lab the board gets straightforward with TFS. You can likewise utilize TFS as back-finish to different advancement conditions (IDEs). Be that as it may, you can just utilize TFS for Microsoft Visual Studio just as Eclipse on all stages.

This blog gives you a stroll through on the best way to get to work things in TFS.

There are various approaches to get to work things in TFS. One of them is TFS API call and another is WIQL (Work Item Query Language). We will examine WIQL in this blog.

Extension

Each undertaking group utilizes a particular Project Management device with the goal that they can deal with their Projects, Tasks, Sprints, and so on In the event that they need to move to TFS for project the executives, moving physically is an extreme assignment as the groups need to make everything on a manual premise.

To beat such issues TFS API is exceptionally helpful as it gives numerous approaches to get and oversee (update/erase) those work things and sync them with their Project the board instrument. This can be useful in saving valuable time and asset.

1. Beginning with TFS

Assuming you haven’t enrolled with Microsoft, first you need to enlist to go on. You can make another one either by utilizing your own email address or by making new email address (@outlook.com/@hotmail.com ).

In the wake of signing into https://visualstudio.microsoft.com/, we need to make another record on which every one of our tasks will be facilitated. We will utilize ‘WorkItemDemo’ (WorkItemDemo.visualstudio.com) as the name of record. Additionally, we will utilize ‘Group Foundation Version Control’ to oversee code for this account.

At the point when you will tap on ‘change subtleties’ it will give 3 info boxes to change following subtleties:

2. Make new Project

When another record is effectively made, another undertaking will likewise be made alongside it. Of course, the undertaking name will be ‘MyFirstProject’ which can be renamed.

We should make some new assignments in ‘MyFirstProject’ project first: (these new errands will be known as TFS API or WIQL in the later stages)

1) From dashboard float on Work (Menu thing) > New Work Item > TaskCreate new Project

2) ‘New Task’ popup will open. Enter every one of the necessary subtleties in separate fields and afterward click on Save and Close catch. Follow a similar interaction to make not many more errand work items.

3. Individual Access Token

To get to all work thing related subtleties from TFS API, we will make PAT (Personal Access Token) for verification.

  • Sign in to your TFS account.
  • From Profile (on upper right corner), click on Security.Personal Access Token
  • Make an individual access token by tapping on ‘Add’ button.Personal Access Token — Add
  • Enter every one of the necessary subtleties and afterward click on ‘Make Token’ button.
  • Ensure you duplicate the recently made token as you will not have the option to see it once more. What’s more, store it’s anything but a protected spot as it very well may be dangerous in the event that it goes into wrong hands.

4. Essential for making Work Items

Following focuses should be satisfied prior to beginning into coding:

  • TFS account.
  • Individual Access Token (PAT)
  • Undertaking having Work Items
  • Visual Studio

5. Getting Work Items from TFS

Post making TFS account, Project, Task things, PAT, and so on we should bring the rundown of undertaking things in our code.

Getting Work Items by utilizing Work Item Query Language (WIQL)

Make new task in Visual Studio and name it according to your comfort. You can make new task with MVC layout.

In the above technique code, constructor “ExecuteQuery()” relegate some significant qualities like URI, PAT, Project name which should be questioned for getting rundown of work things.

In code strategy “RunGetWorkItemsQueryUsingClientLib()”, following code characterizes the inquiry which will choose “State” and “Title” of work things. Likewise, it characterizes that lone specific task will be questioned for getting the outcome which was characterized in constructor technique. Same with condition of the work thing that solitary those work things will be gotten whose state isn’t equivalent to ‘Closed’.RunGetWorkItemsQueryUsingClientLib()

Following code fires the question which is put away in factor named as ‘Inquiry’ in past picture and the consequence of the question will be allocated in ‘workItemQueryResult’.

Finishing code will circle the ‘workItemQueryResult’ variable and repeat on every single thing to get the subtleties of work thing returned by query.workItemQueryResult

Conclusion

This is the manner by which we can utilize WIQL to get the rundown of Work Item(s) from TFS into our custom web application and perform further tasks depending on the situation like store it in DB, show it in some report/lattice and satisfy our prerequisites. Such work things help in tenderizing all your code onto one stage by smoothing out the entire interaction. The particular groups can transfer their variants of the expands on TFS and it guarantee tumult free work space by boosting project conveyance time.

Originally published.

--

--

Gravelsoft

Gravelsoft provides software solutions and solve client’s business challenges by providing expert software engineering and consultancy services.