I would like to avert the "invalid" state change up front by notifying the user or even preventing the change via a Rule. However, I do not see any rule capability's when conditions that are based on the state of linked work items. It would be nice if it would prompt the user if they want to change the state of all children, but I'm pretty sure that would be a feature request. (Extension?)
As of now, I have figured out how to write a query to identify these occurrences after the fact.
SELECT
[System.Id],
[System.WorkItemType],
[System.Title],
[System.State],
[System.AssignedTo],
[Microsoft.VSTS.Common.ResolvedBy],
[Microsoft.VSTS.Common.ClosedBy],
[Microsoft.VSTS.Common.ResolvedDate],
[Microsoft.VSTS.Common.ClosedDate],
[System.AreaPath],
[System.IterationPath]
FROM workitemLinks
WHERE
(
[Source].[System.TeamProject] = @project
AND [Source].[System.State] = 'Closed'
)
AND (
[System.Links.LinkType] = 'System.LinkTypes.Hierarchy-Forward'
)
AND (
[Target].[System.TeamProject] = @project
AND NOT [Target].[System.State] IN ('Closed', 'Removed')
)
ORDER BY [System.Id]
MODE (MustContain)
I'm afraid there is no such way to meet your needs.
We cannot judge whether to close the parent work item based on the status of the child work item.
On the other hand, the state field cannot be used in the rule now.
The state of work items are independent of all other work items, including linked work items.
Now this requirement can only be achieved by manually monitoring the status of the work item.
Since you can create query to get parent and child work items, you could monitor them via the query.
However, this feature is very meaningful. I posted a similar Suggestion Ticket in the UserVoice forum before. You can vote and add comments to express your suggestions.