Unable to get value of custom attribute of type contributor through script
Hi,
I have a custom attribute of type contributor.
I am trying to get the value of the contributor but it is giving null value.
e.g workItem.getValue("test_lead");
When i select the built-in contributor and try to get the value it is giving the proper value
e.g workItem.getValue(WorkItemAttributes.CREATOR);
Below is my script, my custom attribute id is test_lead
dojo.provide("com.example.ContributorValueProvider");
dojo.require("com.ibm.team.workitem.api.common.WorkItemAttributes");
(function() {
var WorkItemAttributes = com.ibm.team.workitem.api.common.WorkItemAttributes;
dojo.declare("com.example.ContributorValueProvider", null, {
getValue: function(attribute, workItem, configuration) {
var out = "";
var test_lead = "";
test_lead+=workItem.getValue("test_lead");
try{
out+=workItem.getValue(WorkItemAttributes.CREATOR)+"\n";
console.log("Going to verify the state is in progress");
if (workItem.getValue(WorkItemAttributes.STATE)=="com.ibm.team.workitem.taskWorkflow.state.s2"){
console.log("IN PROGRESS STATE");
if (workItem.getValue(WorkItemAttributes.CREATOR) == test_lead) {
console.log("COMPARE");
out+="Creator Name: " + workItem.getLabel(WorkItemAttributes.CREATOR)+"\n";
}
}
} catch (e) {
out+=e.message;
}
console.log("Creator:" + test_lead);
return test_lead;
}
});
})();
Thanks in Advance.
One answer
This looks very similar to the issue reported here: https://jazz.net/forum/questions/96178/how-do-i-get-uid-of-the-value-from-custom-attribute-of-type-contributor
for which a work item has been filed. Getting the value for a Contributor for a custom attribute of type contributor seems to not work (by design). According to this wiki article (see JavaScript API section), Contributor is not on the list of types that can be "safely read and returned from scripts".
Comments
does it work for a predefined attribute like Creator? does RTC 3.0.1.1 support getLabel ()?
Contributor, whether used in a built-in or custom attribute, is an attribute type that is not listed as "safely read or returned from scripts". I doubt there is any documentation that would say which particular methods are supported in a particular product version, so the best way to figure out if getLabel() is supported is to just try it.
1 vote