need to get workitem approval status from java script to use in Calculated values script
I am writing a script which will be configured in calcuated values, the script does the following,
Based on a custom field 1 another custom field 2 values is set by checking the wrokitem state and review approval status.
for the same i need to know how can i get review approval state using api.
2 answers
As far as I can tell, you can't access approvals and their states. The attributes accessible are: https://jazz.net/wiki/bin/view/Main/AttributeCustomization#Accessing_built_in_attributes_of and this does not list approvals. It also states that there is limited support for complex value types. E.g. you can not access the team structure and user roles etc. either.
The only chance you have is doing that with Java. See https://rsjazz.wordpress.com/2013/06/26/attribute-customization-java-based-value-providers-conditions-and-validators/ for how to.
The only chance you have is doing that with Java. See https://rsjazz.wordpress.com/2013/06/26/attribute-customization-java-based-value-providers-conditions-and-validators/ for how to.
Comments
Thanks for your response.
Below is my script in one of my project area under calculated values, this script is getting triggered in change of values in field : "com.company.deivationreason" i also want this to get trigger in state change of the work item. but i could not get the result. please suggest me some solution.
Note : i have added the dependence in Type and attributes page.
/********************************************************************************/
/********************************************************************************/
dojo.provide("com.company.SetDeviationApproved");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("com.company.SetDeviationApproved", null, {
getValue: function(attributeId, workItem, configuration) {
var devreason= workItem.getLabel("com.company.deivationreason");
alert (devreason);
var devapproved= workItem.getLabel("com.company.deviationapproved");
var workitemstate= workItem.getLabel(WorkItemAttributes.STATE);
alert(workitemstate);
var devapprv = devapproved;
switch (devreason) {
case "No":
alert ("Not Required");
devapprv = "Not Required";
break;
case "Limited and Parallel":
case "Limited Test Scope":
case "Parallel Release":
case "Test Not Performed":
case "Other":
alert ("We are there ");
if( (workitemstate === "Deviation Approved"))
{
devapprv = "Yes";
}
else
{
devapprv = "No";
alert ("No");
}
break;
default:
alert ("fault");
devapprv = devapproved;
}
return devapprv;
}
});
})();
I can only suggest to carefully read https://jazz.net/library/article/1093 lab 5 and the links above.
With respect to the state, I think the state changes only AFTER the save and you will not get triggered. I know others have crated calculated values that store the last state to figure out if a state change has occurred.
thanks for your reply
As from the script you can understand that, we need to set a custom field value based on approval (review type) value and workitem state. we are left with no clue to implement it. could you help us by providing some solution. ?
thanks !!
You would have to create a server extension. A Follow Up Action (aka Participant) that extends the work item save (server) operation. See
- https://jazz.net/library/article/1000
- https://rsjazz.wordpress.com/2013/02/28/setting-up-rational-team-concert-for-api-development/
- https://rsjazz.wordpress.com/?s=Participant shows some participants as well
If it needs to be a calculated value, you could try it with a Java based provider as explained in https://rsjazz.wordpress.com/2013/06/26/attribute-customization-java-based-value-providers-conditions-and-validators/