TFS 2013 Kanban board Done column (multiple complete states) - tsql

In TFS 2013 Microsoft "fixed" a bug which allowed to map a WorkItem's state to the "Done" state in the Kanban board.
This feature was heavily used in our company. There is a petition to bring it back back but I don't think it will make it:
http://visualstudio.uservoice.com/forums/121579-visual-studio/suggestions/5589316-allow-multiple-complete-meta-state-mapping-in-tfs
In order to migrate TFS2012 to TFS2013 I would like to know where the customized "Done" state columns in TFS 2012 is stored in the database to create a report which shows which team used which WorkItem state as their "Done" state.
TFS2012 Kanban Board looked like that (note the dropdown):
TFS2013 Kanban Board looks like that (note NO dropdown):
I do have access to the TFS Collection database and I would like to create a SQL query which shows me all the customization of this column in TFS 2012.
How can I get for "My WorkItem" the for every Team Project and every Team the customized "Done" state in TFS2012 database?
What other tables do I need to link to in order to get those states?
So far I could only get the TeamId, Name, ColumnType ProjectId but not the effective WorkItem and the "Done" column customization. How can I do that?
SELECT
tbl_Board.TeamId,
tbl_Board.Revision,
tbl_BoardColumn.Name,
tbl_BoardColumn.ColumnType,
tbl_WorkItemTypeExtensions.Description,
tbl_BoardColumn.[Order],
tbl_WorkItemTypeExtensions.ProjectId
FROM
tbl_WorkItemTypeExtensions
RIGHT OUTER JOIN tbl_Board ON
tbl_WorkItemTypeExtensions.Id = tbl_Board.ExtensionId
LEFT OUTER JOIN tbl_BoardColumn ON
tbl_Board.Id = tbl_BoardColumn.BoardId

Experts do not recommend accessing TFS DB but you can use Tfs_WarehouseDatabase if Reporting is configured and Data from all project collections is collected and stored in tables that are optimized for reporting.
I do not have a knowledge about the db structures of TFS but going through few important online articles I managed understood quiet a few about it and as I understood the information that is required for you is in WorkItemsAretable.
Team Foundation Server Databases
Work item field and database schema reference
Stack overflow Question Access the Kanban Column (a Team-Specific Field) for a Work Item
With those queries below you can get the state of a certain work item on the Kanban board:
USE Tfs_DefaultCollection
SELECT TOP(10)
MarkerField + 1 as FieldId,
*
FROM tbl_WorkItemTypeExtensions with(nolock)
JOIN tbl_projects on tbl_WorkItemTypeExtensions.ProjectId = tbl_projects.project_id
WHERE tbl_projects.project_name LIKE '%ProjectName%
Copy the result from "FieldId" column to below's query at position XXXXXXXX
SELECT TOP 1000
wid.Id,
wia.State,
wid.StringValue as Kanban,
wia.[Work Item Type],
wia.Title,
tn.Name as Iteration
FROM tbl_WorkItemData wid with(nolock)
JOIN WorkItemsAre wia on wia.ID = wid.Id
JOIN TreeNodes tn on wia.IterationID = tn.ID
WHERE FieldId = XXXXXXXX and RevisedDate = '9999-01-01 00:00:00.000'
ORDER BY Id
Create a Detailed Report using Report Designer
Hope the sources that I have provided above will help your problem!

I contacted the Microsoft Support and they provided me the following answer to my question:
SELECT
board.TeamId,
boardColumn.Name,
workItemTypeExtensions.Rules
FROM
tbl_Board board JOIN
tbl_WorkItemTypeExtensions workItemTypeExtensions ON board.ExtensionId = workItemTypeExtensions.Id JOIN
tbl_projects projects ON workItemTypeExtensions.ProjectId = projects.project_id JOIN
tbl_BoardColumn boardColumn ON board.Id = boardColumn.BoardId
WHERE
projects.project_name LIKE '%< ENTER YOUR PROJECT NAME HERE >%' AND
boardColumn.ColumnType = 2
ORDER BY
board.TeamId,
boardColumn.[Order]
When I check XML in the "Rules" column there I can find exactly what I was looking for.

Related

uSync Dropdown DataType Issue

I have 2 sites, dev branch and production. On my dev branch I'm using a couple of archetype DataType which are able to be configured by a simple dropdown with couple color names (like Green, Blue etc). I have like 300 published nodes which uses that datatype (required field). After I've exported "Full Export" in uSync dashboard and then copy/pasted the whole uSync folder to my production branch and clicked "Full Import". After import complete I check my nodes. All fields are there except that dropdown.
There are some old issues on the our.umbraco.com website stating the same issue, but they seem to been fixed.
I've posted there this issue, but has been 6 days, and the topic still is on manual approval.
Any idea what must be causing this issue?
I am using (uSync.BackOffice 4.0.16.0) (uSync.Core 6.0.15.0) [uSync.Content: 4.1.9.1]
Umbraco version 7.15.4
Thank you in advance.
Best regards,
Artur
PS. I am unable to create the USync label. Would appreciate if someone would edit with it!
I'd open up the database and look at the values in the cmsDataTypePreValues table. I suspect that uSync has changed the prevalues out from under you. Prevalues are really tricky and uSync does its best given the circumstances. You'll notice that the uSync .def files in Umbraco 7 don't record any unique ids on those prevalues. They just get inserted into the database and are assigned an id automatically. This means if the prevalues are deleted and recreated, they will have different ids. If those dropdown prevalues are being picked by the id field on the cmsDataTypePreValues record, that is probably what is going wrong.
Use the following query to see your prevalues for the datatype:
DECLARE #dataTypeNodeId AS INT = <dataTypeNodeId, INT, 0>
SELECT *
FROM cmsDataType dt
INNER JOIN cmsDataTypePreValues pv
ON pv.datatypeNodeId = dt.nodeId
WHERE dt.nodeId = #dataTypeNodeId
Compare the values you see here between the dev database and the production database. To help give you a better picture of what the data looks like, you could also run this query to see what the actual picked values look like. The query is so long because it is filtering out results from old versions. This might not work very well for you because your datatype is inside of Archetype. Hopefully it can still give you an idea about what selected dropdown values actually look like in the database.
DECLARE #dataTypeNodeId AS INT = <dataTypeNodeId, INT, 0>
SELECT TOP 1000 n.id
,n.[text]
,n.[path]
,pt.[alias] AS 'property alias'
,dtn.id AS 'Datatype Id'
,dtn.[text] AS 'Datatype Name'
,dtn.uniqueID AS 'Datatype Guid'
,d.templateId
,t.[alias] AS 'template alias'
,pd.dataInt
,pd.dataDate
,pd.DataNvarchar
,pd.dataNtext
,cv.VersionDate
FROM umbracoNode n
INNER JOIN cmsDocument d
ON d.nodeId = n.id
INNER JOIN cmsContentVersion cv
ON cv.VersionId = d.versionId
INNER JOIN cmsPropertyData pd
ON pd.contentNodeId = n.id AND pd.versionId = d.versionId
INNER JOIN cmsPropertyType pt
ON pt.id = pd.propertytypeid
INNER JOIN cmsDataType dt
ON dt.nodeId = pt.dataTypeId
INNER JOIN umbracoNode dtn
ON dtn.id = dt.nodeId
LEFT OUTER JOIN cmsTemplate t
ON t.nodeId = d.templateId
WHERE d.newest = 1
AND dtn.id = #dataTypeNodeId
You can try to manually fix the prevalue entries in the database. I've run into enough prevalue trouble with Umbraco dropdowns that I try to always use something like nuPickers to avoid picking prevalues by id.

Report Of Work Items & Their Parents

Hey Folks my org recently migrated from TFS 2017 to VSTS online. Our IT Finance team has a report that show work items along with their parents and your grandparents. It was built around a SQL query that looked at the backend SQL database. Is there a way to create a report of all work items and their parents in VSTS online?
Yes, it’s possible to show all the work items as parent/child relation in VSTS. Detail steps as below:
Create a new query with Tree of work items type.
Add the filter Work Item Type = [Any] both for top level work items and linked work items. And select Parent/Child Type of tree, then save the query.
Run the query and you will get all the work items with tree view relations.

SSRS subquery based on other query

I'd like to make an overview of projects.
This contains some fixed info; table projects joined with some other tables.
Now the report needs to have some subqueries: how many sales per salesman, how many is in transit, inventory, ... and so on.
I have a tablix with grouping on project (as to create an excel with one worksheet per projet).
How would I go about executing a new subquery per project (f.e. select owner, sum(totalprice) from opportunities where project=xxx group by owner)
I know I could achieve this with subreports; but as I will have about 10 subreports, I was hoping I could solve this with extra datasets and some filtering (and thus keep all logic in one file).
What's the best way to achieve this?
I would create a dataset with this query:
select owner, project, sum(totalprice) as totalprice from opportunities group by owner, project
Next, in your tablix where you want to display owner and totalprice info, you will have an expression like this:
=LOOKUP(Fields!<FirstDataSetProjectFieldName>.Value, Fields!project.Value, Fields!owner.Value, "<NewDatasetName>")
The above code will send the value of the project you are searching for, match it with a the same field in your new dataset, then return the requested value from the new dataset. You can obviously do this for totalprice as well.
Check out the documentation for LOOKUP to get a better handle on it but I think this is the solution you are looking for.

Get list of all files with the user who checked in the latest version in TFS

Is there a way in TFS to get a list of files under source control with the user who checked in the latest version/version you have locally.
The closest functionality to this that i can find is in the source control explorer window you can see each files with the latest check-in date, but not with the user who checked it in.
There is no way currently from the VS Source control explorer. The best you can get is using the Web TFS version. You will see the name of the user in the comments section (in orange in the image below) along with changset # and any comment.
If that doesn't work for you somehow then you can either use TFS Api or SQL query against TFS DB. Following SQL should give you the result.
SELECT TOP 10
V.ChildItem AS [FileName],
I.DisplayName AS [ChangedBy],
CS.CreationDate AS [ChangeDate]
FROM tbl_Changeset CS
INNER JOIN tbl_Identity I
ON I.IdentityID = CS.OwnerID
INNER JOIN tbl_Version V
ON V.VersionFrom = CS.ChangesetID

T-SQL Trigger After Delete

Situation: Let's say you have a database of organizations, students, and course purchases, and an administrator wants to get a refund for a course they assigned out. The software doesn't support refunds by default. You don't have access to the source code, but you can set up triggers in the database.
Database Structure:
organizationsorganization_idaccount_balance
studentsstudent_idorganization_id
purchasesstudent_idtime_of_purchaseamount_to_refund
General idea is that, when an entry (or more than one!) is removed from the purchases table, a trigger runs to update the account balance of the appropriate organization. amount_to_refund can be null or zero, so no refund is given in that case. Refunds should also not be given if time_of_purchase was more than 30 days ago.
Any ideas how to pull this off? I've been modeling it off of another trigger, but am getting thrown off by the UPDATE ... FROM ... syntax, which I can't say I've used before. I have looked at MSDN, but I'm a bit overwhelmed.
Optionally, I'd also like to insert rows into another table (not documented here) containing the refund amount and organization ID. I just need a general idea where this fits in and can probably handle the rest myself.
CREATE TRIGGER [dbo].[TrgPurchasesDelete] ON [dbo].[Purchases] FOR DELETE
AS
BEGIN
UPDATE
[dbo].[Organizations]
SET
account_balance = account_balance + DLTD.ammount_to_refund
FROM
[dbo].[Organizations] ORGA
INNER JOIN [dbo].[Students] STDT ON
STDT.organization_id = ORGA.organization_id
INNER JOIN DELETED DLTD ON
DLTD.student_id = STDT.student_id
WHERE
DLTD.ammount_to_refund > 0
AND DLTD.time_of_purchase > DATEADD(DAY, -30, SYSDATE)
END
GO