Reputation: 20169
I have an Azure DevOps Extension that I need to update a ReadOnly Custom Work Item field.
The Custom Field is being set to ReadOnly via a Process Rule.
I realize I can do something like this and bypass the rule via the full API itself:
fetch('https://dev.azure.com/aherrick/_apis/wit/workitems/1?api-version=7.0&bypassRules=true', {
method: 'PATCH',
headers: {
'Content-Type': 'application/json-patch+json',
"Authorization": "Basic " + btoa("" + ":" + "PAT")
},
body: JSON.stringify([{
"op": "add",
"path": "/fields/Custom.MyField",
"value": "100"
}])
});
However, I don't want to have to embed a PAT in my Azure DevOps Extension. I've tried something like this using the VSS Work Item Client:
var document = [{
"op": "add",
"path": "/fields/Custom.MyField",
"value": "10001"
}];
witClient.updateWorkItem(document, 1)
.then(function (response) {
console.log(response);
}, function (error) {
console.log(error);
});
However, how do I Bypass Rules using the built in VSS Work Item Client? Any other suggestions on how to accomplish this?
Upvotes: 0
Views: 526
Reputation: 20169
What I've come up with seems to work but is a total hack. Essentially I'm using a hidden custom "backing field" that when set to a value (via a rule) my proper custom field is set to read only.
So in code, I force the backing field and remove it's value (thus removing read only from my proper custom field), actually update my custom field, then reset the backing field. :(
There has to be a cleaner way?
Upvotes: 0