In a nutshell, I created an inherited process from the REST API, when I try to add a state or a field, I get an error because it uses the reference name from the original work item, not it’s own.
For example: Microsoft.VSTS.WorkItemTypes.Bug
instead of processName.Bug
.
function newProcess {
param (
[Parameter(Mandatory)] [string] $organization,
[Parameter(Mandatory)] [string] $process,
[Parameter(Mandatory)] [string] $description,
[Parameter(Mandatory)] [string] $parent,
[Parameter(Mandatory)] [hashtable] $header
)
[string] $uri = "https://dev.azure.com/{0}/_apis/work/processes?{1}" -f $organization, $apiVersion
[string] $body = @{ name = $process; parentProcessTypeId = (getProcessId -organization $organization -process $parent -header $header); description = $description } | ConvertTo-Json
try {
[string] $id = (Invoke-RestMethod -Uri $uri -Method Post -ContentType application/json -Body $body -Headers $header).typeId
Start-Sleep -Seconds 1.0
if ( $id -eq (getProcessId -organization $organization -process $process -header $header) ) {
Write-Host " - Process '$process' successfully created in organization $organization !"
return ($id)
} else {
throw
}
} catch {
Write-Host "##[error] An error occurred while creating the Process $process in the organization $organization at $uri"
Get-Error
throw
}
}
If I update the state or field from Azure manually, it will change the name, how can I automate that from the Azure REST API?
2
Answers
To start editing work item types in the inherited process, create the inherited work item type. Use this method Work Item Types – Create and add this reference:
For the newly created inherited process, you should create an inherited work item type before editing it as mentioned by @Shamrai Aleksander. For each work item type, if you want to change it, you need to create a corresponding inherited work item type. Change the value of
ParentWorkItemType
below.