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:
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.
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;}
});
})();
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
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.
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
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.
Comments
Jesse Timbang
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.