Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to modify BoardColumn field of a Work Item using REST API

I have a customized Board with:

  • First default column "New" mapped to "New" state.

  • Second column "To do" also mapped to "New" state (After weekly reviewing new WI, team moves them in this column to avoid reviewing them next time).

In the TFS Board I can move a WI from the First Column to the second columun.

With the REST API when I read an existing WI, I got the right information for the BoardColumn field.

But when I used the REST API to modify BoardColumn it raises an exception.

I have the bypass rules permission.

 $tfsTargetUri = "https://path to my collection/"
 $tfsTargetProject = "MyProject"
 $MyWI = 56 #use an existing Id
 $mycredentials = Get-Credential

 $workitem2 =
 @(
 @{op="test";path="/rev";value="1"},
 @{op="add";path="/fields/System.BoardColumn";value="New"}
 #@{op="add";path="/fields/System.State";value="Active"}
 )

 $json2 = $workitem2 | ConvertTo-Json  -Depth 100
 $url2= $tfsTargetUri + $tfsTargetProject + '/_apis/wit/workitems/' + $MyWI +'?bypassRules=true&api-version=2.0'
 $targetbug = Invoke-RestMethod -Uri $url2 -Method Patch -Credential $mycredentials -Body ([System.Text.Encoding]::UTF8.GetBytes($json2)) -ContentType 'application/json-patch+json' 

When I try with BoardColumn in workitem2 it raises an exception.

When I modify the comment in workitem2 to change the State field, this is working.

Any idea?

like image 333
Dominique Avatar asked Jan 20 '26 03:01

Dominique


1 Answers

The field System.BoardColumn is read only by design, is not a regular work item rule, so bypass = true can helps in this case. This is the reason why you can not update this field with the regular way.

According to new Microsoft Docs you provided (the relevant section added 3 days ago) there is a solution. You can update the field if you update another field value - if you get the work item and investigate the fields you will see this kind of field:

WEF_432678B52358ACDA34ASDA243489FD343_Kanban.Column

When you update this field to the Board Column State the work item will move to this Board Column.

Example how to extract this field from work item details:

$url = $collection/_apis/wit/workitems/$id?api-version=4.0
$workItem = Invoke-RestMethod -Uri $url -Method Get ...
$boardColumnField = $workItem.fields.PSObject.Properties.Name.Where({$_.Contains("Kanban")})[0]

# Now in the work item json use it: /fields/$boardColumnFied
like image 184
Shayki Abramczyk Avatar answered Jan 22 '26 16:01

Shayki Abramczyk



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!