How to update severity/state of work item usinfg REST api ?
2 answers
I've already done a state Change.
That's the way I do it.
1: Require this:
var WorkItemProxyFactory = com.ibm.team.workitem.web.cache.internal.WorkItemProxyFactory;
2: Load the wished Workitem:
this.workingCopyProxy = WorkItemProxyFactory.getWorkItemProxy({id: this.currentId, createIfNeeded: true, doNotCache: true, doNotGetFromCache:true});
this.workingCopyProxy.initialize({});
3: Check the state you have. Because you have to stick to the logic... new -> open -> done.
This means, you can't directly change from new to done.
E.g.
var proxyState = this.workingCopyProxy.getValue({path: 'attributes.internalState.label'});
var aValues= this.workingCopyProxy.getEditPropsValuesForAttribute('actionValues');
if (proxyState == 'Done') {
console.log('This is Done. Do nothing')
} etc
---------------------
_changeStartWorkingToDone: function() {
var action_id = this._getWorkflowActionIdWCopy('Set Done', this.workingCopyProxy);
if (action_id != '') {
var params = this._getParamsForWorkflowAction(action_id);
this.workingCopyProxy.setValue(params);
this.workingCopyProxy.storeWorkItem({
operationMsg: 'Saving',
applyDelta: true,
onSuccess: function(parms) {
},
onError: function(error) {
console.log(error);
}
});
}
},
_getWorkflowActionIdWCopy: function(actionLabel, workingCopy) {
var aValues = workingCopy.getEditPropsValuesForAttribute('actionValues');
console.log(aValues.length);
console.log(">>>>>>>>>>>>>>>><");
var action_id = '';
for (i in aValues) {
if (aValues[i].label == actionLabel) {
action_id = aValues[i].id;
break;
}
}
return action_id;
},
-----------
_getParamsForWorkflowAction: function(action_id) {
var params = {};
params.attributeId = 'workflowAction';
params.isInitialization = false;
params.path = ["attributes", "workflowAction", "id"];
params.value = action_id;
return params;
},
That's the way I do it.
1: Require this:
var WorkItemProxyFactory = com.ibm.team.workitem.web.cache.internal.WorkItemProxyFactory;
2: Load the wished Workitem:
this.workingCopyProxy = WorkItemProxyFactory.getWorkItemProxy({id: this.currentId, createIfNeeded: true, doNotCache: true, doNotGetFromCache:true});
this.workingCopyProxy.initialize({});
3: Check the state you have. Because you have to stick to the logic... new -> open -> done.
This means, you can't directly change from new to done.
E.g.
var proxyState = this.workingCopyProxy.getValue({path: 'attributes.internalState.label'});
var aValues= this.workingCopyProxy.getEditPropsValuesForAttribute('actionValues');
if (proxyState == 'Done') {
console.log('This is Done. Do nothing')
} etc
---------------------
_changeStartWorkingToDone: function() {
var action_id = this._getWorkflowActionIdWCopy('Set Done', this.workingCopyProxy);
if (action_id != '') {
var params = this._getParamsForWorkflowAction(action_id);
this.workingCopyProxy.setValue(params);
this.workingCopyProxy.storeWorkItem({
operationMsg: 'Saving',
applyDelta: true,
onSuccess: function(parms) {
},
onError: function(error) {
console.log(error);
}
});
}
},
_getWorkflowActionIdWCopy: function(actionLabel, workingCopy) {
var aValues = workingCopy.getEditPropsValuesForAttribute('actionValues');
console.log(aValues.length);
console.log(">>>>>>>>>>>>>>>><");
var action_id = '';
for (i in aValues) {
if (aValues[i].label == actionLabel) {
action_id = aValues[i].id;
break;
}
}
return action_id;
},
-----------
_getParamsForWorkflowAction: function(action_id) {
var params = {};
params.attributeId = 'workflowAction';
params.isInitialization = false;
params.path = ["attributes", "workflowAction", "id"];
params.value = action_id;
return params;
},