It's all about the answers!

Ask a question

need to get workitem approval status from java script to use in Calculated values script


Praveen Kumar (611) | asked Feb 18 '15, 11:05 p.m.
edited Feb 19 '15, 11:04 a.m. by Ralph Schoon (63.1k33646)
 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



permanent link
Ralph Schoon (63.1k33646) | answered Feb 19 '15, 2:48 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
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.

Comments
Praveen Kumar commented Feb 19 '15, 8:28 a.m. | edited Apr 28 '15, 11:33 p.m.
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;
    }
});
})(); 

Ralph Schoon commented Feb 19 '15, 9:45 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

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.


Praveen Kumar commented Feb 20 '15, 3:27 a.m. | edited Apr 28 '15, 11:33 p.m.

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 !!


permanent link
Ralph Schoon (63.1k33646) | answered Apr 29 '15, 2:17 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
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/


Comments
Ralph Schoon commented Apr 29 '15, 2:19 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

There is a post on rsjazz about approvals and their data. The WorkItemCommandline has all the code you'd need and one participant creates and approval.

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.