It's all about the answers!

Ask a question

Unable to get value of custom attribute of type contributor through script


Abuzaid Shaikh (89145) | asked Feb 11 '13, 4:31 p.m.
edited Apr 02 '13, 4:40 a.m. by Ralph Schoon (55.8k23642)
 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



permanent link
Millard Ellingsworth (2.5k12431) | answered Feb 11 '13, 5:08 p.m.
FORUM ADMINISTRATOR / JAZZ DEVELOPER
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
David Murphy commented Apr 11 '13, 12:00 p.m.

does it work for a predefined attribute like Creator?  does RTC 3.0.1.1 support getLabel ()?


1
Millard Ellingsworth commented Apr 11 '13, 3:26 p.m.
FORUM ADMINISTRATOR / JAZZ DEVELOPER

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. 

Your answer


Register or to post your answer.