Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Attribute customization in RTC

 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

0 votes

Comments

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

1 vote

Comments

  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.

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

0 votes

Comments
Yes that took care of it. 
I edited it a bit and now it looks like:

 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";
}
}
}

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 log in 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 12,019

Question asked: Feb 25 '14, 7:54 a.m.

Question was seen: 7,309 times

Last updated: Feb 26 '14, 5:47 p.m.

Confirmation Cancel Confirm