Veverke
Veverke

Reputation: 11338

How to automatically assign PBI tasks to the same assignment as of the PBI?

I must be doing something wrong.

Say I have a Feature. Assign it to John. Create PBIs (Product Backlog Items) for it. Break the PBIs down into tasks.

Is not there a way to automatically have the tasks and PBIs assigned to the same Feature assignment ?

I am not able to achieve such result.

Docs in adding tasks for a PBI, for example, do not mention how to do that - and in the screenshots one can see it is by default created unassigned.

I can't find docs that tell how to have them automatically assigned to the assignment of the parent item.

Upvotes: 1

Views: 1862

Answers (3)

Shamrai Aleksander
Shamrai Aleksander

Reputation: 15998

There is no "out-of-box" automation to assign work items from parent items. There is no sense to do that because one feature may be performed by several teams and one story may be developed by several developers/testers. However, you can use Rest Api for custom automation. As an example, how to move AssignedTo from parent Feature to child User Stories through PowerShell:

$user = ""
$token = "<pat>" #https://learn.microsoft.com/en-us/azure/devops/organizations/accounts/use-personal-access-tokens-to-authenticate?view=azure-devops&tabs=Windows

$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user,$token)))

$org = "<OrgName>"
$teamProject = "<TeamProject>"
$parentWIType = "Feature"
$childWIType = "User Story"

function InvokeGetRequest ($GetUrl)
{   
    return Invoke-RestMethod -Uri $GetUrl -Method Get -ContentType "application/json" -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)}
}

function InvokePostRequest ($PostUrl, $Body)
{   
    return Invoke-RestMethod -Uri $PostUrl -Method Post -ContentType "application/json" -Body $Body -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)}
}

function InvokePatchRequest ($PatchUrl, $Body)
{   
    return Invoke-RestMethod -Uri $PatchUrl -Method Patch -ContentType "application/json-patch+json" -Body $Body -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)}
}

$restApiWiql = "https://dev.azure.com/{0}/{1}/_apis/wit/wiql?api-version=7.1-preview.2" -f $org, $teamProject

$wiQuery = "SELECT [System.Id] FROM WorkItemLinks WHERE ([Source].[System.TeamProject] = '{0}'  AND  [Source].[System.WorkItemType] = '{1}' AND  [Source].[System.AssignedTo] <> '') And ([System.Links.LinkType] = 'System.LinkTypes.Hierarchy-Forward') And ([Target].[System.WorkItemType] = '{2}'  AND  [Target].[System.AssignedTo] = '') ORDER BY [System.Id] mode(MustContain)"

$queryStr = $wiQuery -f $teamProject, $parentWIType, $childWIType

$queryBody = "{`"query`":`"$queryStr`"}"

$result = InvokePostRequest $restApiWiql $queryBody

foreach ($relation in $result.workItemRelations)
{
    if ($null -ne $relation.source)
    {
        $restApiGetWi = "https://dev.azure.com/{0}/{1}/_apis/wit/workitems/{2}?api-version=7.1-preview.3" -f $org, $teamProject, $relation.source.id

        $parentWi = InvokeGetRequest $restApiGetWi

        $updateBody = '[{{"op": "add", "path": "/fields/System.AssignedTo", "value": "{0}"}}]' -f $parentWi.fields.'System.AssignedTo'.displayName


        $restApiUpdateWi = "https://dev.azure.com/{0}/{1}/_apis/wit/workitems/{2}?api-version=7.1-preview.3" -f $org, $teamProject, $relation.target.id

        InvokePatchRequest $restApiUpdateWi $updateBody
    }
}

Upvotes: 0

RFMoore
RFMoore

Reputation: 29

If the creation of the Product Backlog Item (PBI), is added from within the Feature the Parent-Child relation is automatically associated. The same logic applies for the creation of Tasks from within a PBI.

How: If within the Product Backlog (Azure DevOps - Boards > Backlogs > [Specific backlog] > [specific Feature] ...

  • select "Add link" under "Related Work"
  • Select "New Item"
  • Add title. The link type should be pre-selected as "Child" with "Work item type" as PBI

Upvotes: 1

jessehouwing
jessehouwing

Reputation: 114491

You can setup a service hook or a project like aggregator-cli to trigger rules to perform automatic work item updates.

https://github.com/tfsaggregator/aggregator-cli

These can then copy the assigned to from parent to child if unassigned.

The default to leave them empty makes a lot of sense in my eyes. It's rare that a single team member takes on responsibility to develop and test a whole feature by themselves. It's usually recommended to work together to deliver a feature together as a team. On scrum and other agile approaches it's also more common for a developer to self-assign an item, not to get it assigned by someone else. Azure Boards' setup reflects this.

Upvotes: 1

Related Questions