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

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.

0 votes



One answer

Permanent link
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".

1 vote

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

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
× 10,937
× 152

Question asked: Feb 11 '13, 4:31 p.m.

Question was seen: 7,266 times

Last updated: Apr 11 '13, 3:26 p.m.

Confirmation Cancel Confirm