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
|
Accepted answer
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");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){
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
Dinesh Kumar B (4.1k●4●13)
| 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 : 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
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.
Comments
Reopened Flag is the name/label as it appears on the work item, and Reopened is the name of the attribute.