Extending TFS in NAV

Hi all,

some time ago I created project named TFS2NAV. Now it is time to tell you what you can do with it.

If you are using Dynamics NAV in your company and you are using TFS (on-prem or Team Services), this project helps you to extend the TFS by passing information about different things from TFS into your NAV. Than you can develop own process in NAV to do what you want.


How it works?

TFS has feature named Service Hooks. Service Hooks are web services, which could be called when something happens inside TFS. And which events you can hook?

  • Build completed
  • Code pushed
  • Pull request created
  • Pull request merge commit created
  • Pull request updated
  • Release abandoned
  • Release created
  • Release deployment approval completed
  • Release deployment approval pending
  • Release deployment completed
  • Release deployment started
  • Team room message posted
  • Work item commented on
  • Work item created
  • Work item deleted
  • Work item restored
  • Work item updated
Each event has own filters you can apply to the hook.
The hook could be some external service and there are several service types supported:
  • Azure Service Bus
  • Azure Storage
  • Bamboo
  • Campfire
  • Flowdock
  • HipChat
  • Jenkins
  • Slack
  • Trello
  • Web Hooks
  • Zendesk
Not all services are supporting all events, and some services have different supported actions. On Team services you have more types available. I have selected the Web Hooks, because they are supporting all events and are just calling some webservice through HTTP Post action.
Part of the definition of the service hook is URL of the service. It means that you select which event you want to subscribe, which service type you want to connect, URL of the service, some additional options and voala, you are done! When something happens in TFS, the hook will deliver data to selected service. And the TFS2NAV allows you to deliver the data into NAV webservice.

How to use TFS2NAV as Service Hook

Download the code from github, compile, publish to your IIS. In the web.config there are some settings you need to set:
  • TFS2NAVService_NAV_TFS2NAV - URL of your NAV Webservice (any function with one Text parameter returning Text)
  • WSUserName - user name for authentication to the NAV WebService
  • WSUserPwd - password for the account
  • WSUserDomain - domain of the user
  • WSauthType - type of authentication (NTLM /Windows)

Create new Service Hook in TFS, select Web Hooks service, Select trigger you want, set the filters. Now set the URL to something like http://server:port/TFS2NAV/TFS2NAVListener.svc/ToNAV. Test the service through Test button. It will generate some dummy event and will show you the result. If all is OK (the message wen through TFS2NAV into your NAV webservice), you can Finish the process and your hook is prepared.

Because the data are passed into NAV as Json, it is on you to parse it, but you can find how to do that e.g. here.


Now you have a way how to connect TFS and e.g. your internal management system in NAV. And because you can manipulate TFS data through REST API, why not to connect your NAV to TFS through it and when needed change something from NAV? You can look at the TFS REST API here. And how to call REST service from NAV here.

As you can see, we a using REST (OData) more and more and you can connect your NAV with different services through that. I hope that it will comes your management system to new level, when you will be able connect your data with processes in DevOps and you will do more through automatic processes using TFS+PowerShell+NAV.