It's all about the answers!

Ask a question

Attribute customization in RTC


Jesse Timbang (3211519) | asked Feb 25 '14, 7:54 a.m.
edited Feb 25 '14, 7:56 a.m.
 Hi everyone,
I have an boolean attribute called Reopened Flag and the plan is to put a check on this flag (basically put it to True) whenever the work item reaches a certain Status. I read about the work item attribute customization guide here:
https://jazz.net/wiki/bin/view/Main/AttributeCustomization
but I'm unable to make it happen. Here's the js that I'm using by the way:


dojo.provide("org.example.workitems.providers.Reopen");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");

(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;

dojo.declare("org.example.workitems.providers.Reopen", null, {

    getValue: function(attributeId, workItem, configuration) {
    {
var reopen = workItem.getValue(WorkItemAttributes.REOPENED); 
var ret = "False";
var state = workItem.getValue(WorkItemAttributes.STATE); 
if (state == 6){
ret="True";
}
         
return ret;}
});

})();


I think the problem is with how I return the value

Comments
Jesse Timbang commented Feb 25 '14, 7:57 a.m.

Reopened Flag is the name/label as it appears on the work item, and Reopened is the name of the attribute. 

Accepted answer


permanent link
Dinesh Kumar (4.0k413) | answered Feb 25 '14, 10:50 a.m.
JAZZ DEVELOPER
if reopened is what needs to be kept track of, i would
    read the reopened attribute value and
    on finding that it is already true,
    just return back the value with no further processing..

in your case, i see a similar approach using
   var reopen = workItem.getValue(WorkItemAttributes.REOPENED);

however, I believe you are working with a custom attribute of type boolean and not a built in attribute.  Only some of the built-in attributes can be read using the
    var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
followed by
    workItem.getValue(WorkItemAttributes.REOPENED);

what you would require is to use the ID of the custom attribute provided to the workItem.getValue API in double quotes, as in
    workItem.getValue("customAttributeID");


here is a sample script that works for me:

dojo.provide("com.example.ValueProvider.setCheckBool");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
var WorkItemAttributes= com.ibm.team.workitem.api.common.WorkItemAttributes;
    dojo.declare("com.example.ValueProvider.setCheckBool", null, {
    getValue: function(attribute, workItem, configuration) {

  var ret = "False";
    var reopen = workItem.getValue("checkbool");
   var state = workItem.getValue(WorkItemAttributes.STATE); 
  
   console.log("State is : " + state + " and Reopened : " + reopen);
  
   if( reopen == true){
      ret="true";
   }
  
   if (state == "3"){
   ret="true";
   }
           
   return ret;}

    });
})();
this might as well be the reason for the Problems in loading the script.
Jesse Timbang selected this answer as the correct answer

Comments
Jesse Timbang commented Feb 26 '14, 5:34 p.m.

  if( reopen == true){ 
      ret="true"; 
   } 


does not return back the value with no further processing..it still removes the check mark.

How does one see the logging anyway? On the browser? I don't see any console logging on firebug.


Jesse Timbang commented Feb 26 '14, 5:47 p.m. | edited Feb 26 '14, 5:47 p.m.

I misread what you've typed in, Dinesh. I did not get to the part where I have to specify the id of the custom attribute. Everything is working correctly now thank you!

One other answer



permanent link
Dinesh Kumar (4.0k413) | answered Feb 25 '14, 8:26 a.m.
JAZZ DEVELOPER
edited Feb 25 '14, 8:34 a.m.
your return statement is fine...

workItem.getValue on STATE returns a string value :
    workItemGetValue

so, use a string format for comparison...

modify
    if (state == 6)
to
   if (state == "6")

i checked with a similar code and it works..

hope it helps.

Comments
Jesse Timbang commented Feb 25 '14, 10:29 a.m.
Yes that took care of it. 
I edited it a bit and now it looks like:

Jesse Timbang commented Feb 25 '14, 10:30 a.m.

 getValue: function(attributeId, workItem, configuration) {

var reopen = workItem.getValue(WorkItemAttributes.REOPENED); 
var state = workItem.getValue(WorkItemAttributes.STATE); 
if (reopen == "True"){
return "True";
} else {
if (state == "6"){
return "True";
}
}
}


Jesse Timbang commented Feb 25 '14, 10:31 a.m.

Now I'd like for it to keep the check mark even if I move the status to anything other than reopened though, but when I do that the check mark is gone.

Your answer


Register or to post your answer.