I am trying to add a parent link when I create TFS task via powershell. However, I am only able to add a related link:
function Create-New-WorkItem($projName, $taskType, $title, $state, $assignedTo, $iterationPath, $activity, $BLItem)
{
$tfs = Get-TfsServer
$ws = $tfs.GetService([type]"Microsoft.TeamFoundation.WorkItemTracking.Client.WorkItemStore")
$proj = $ws.projects[$projName]
$workitem = $proj.workitemtypes[$taskType].newworkitem()
$workitem.open()
$workitem.title = $title
$workitem.state = $state
$workitem.fields["Assigned To"].value = $assignedTo
$workitem.iterationpath = $iterationPath
$workitem.fields["Activity"].value = $activity
$id = Get-Parent-Link $BLItem
$workitem.links.add($id.ID)
$workitem.close()
$workitem.save()
}
function Get-Parent-Link($backLogItemName)
{
$tfs = Get-TfsServer
$WIQL = @"
SELECT [System.Id]
FROM WorkItems
where [System.Title] = '$backLogItemName'
"@
return $tfs.wit.query($WIQL)
}
How can I add the link as a parent instead of a related?