How to use javascript to retrieve value of Contributor attirbute
I am customizing process template with javascript so that value of contributor attribute can be retrieved. Now I heard that "username need to be used to retrieve unique ID so that the ID can be used to retrieve value from contributor list and there is API that can be used"
Could anyone provide more information on how it can be achieved?
or is it not possible? (https://jazz.net/forum/questions/80964/how-to-get-contributor-name-by-javascript)
It would be great if someone can clarify this
Could anyone provide more information on how it can be achieved?
or is it not possible? (https://jazz.net/forum/questions/80964/how-to-get-contributor-name-by-javascript)
It would be great if someone can clarify this
2 answers
Currently you can only use .getValue() and getLabel() in scripts. That will give you the internal Id and the visible user name/id(?) for an attribute of type contributor. I am not aware of a way to query for user Ids or names in scripts except reading a contributor type attribute with a valid contributor already being set. This holds for RTC 3.x and 4.x as far as I am aware.
Comments
The post http://rsjazz.wordpress.com/2012/08/02/subscribing-to-a-work-item-using-the-java-api/ is about the Plain Java Client Libraries and not related to JavaScript. It is a pure Java RTC Client.
I am not sure if it is possible to get at an approver using Java script.
The example below, if configured as calculated value provider for a string such as description and a dependency to the attribute (Created By) will show the contributor ID and name in the string.
/*******************************************************************************
* Licensed Materials - Property of IBM
* (c) Copyright IBM Corporation 2011. All Rights Reserved.
*
* Note to U.S. Government Users Restricted Rights:
* Use, duplication or disclosure restricted by GSA ADP Schedule
* Contract with IBM Corp.
*******************************************************************************/
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 = "";
try{
out+="Creator ID: " + workItem.getValue(WorkItemAttributes.CREATOR)+"\n";
out+="Creator Name: " + workItem.getLabel(WorkItemAttributes.CREATOR)+"\n";
} catch (e) {
out+=e.message;
}
console.log("Creator:" + out);
return out;
}
});
})();
I am not sure if it is possible to get at an approver using Java script.
The example below, if configured as calculated value provider for a string such as description and a dependency to the attribute (Created By) will show the contributor ID and name in the string.
/*******************************************************************************
* Licensed Materials - Property of IBM
* (c) Copyright IBM Corporation 2011. All Rights Reserved.
*
* Note to U.S. Government Users Restricted Rights:
* Use, duplication or disclosure restricted by GSA ADP Schedule
* Contract with IBM Corp.
*******************************************************************************/
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 = "";
try{
out+="Creator ID: " + workItem.getValue(WorkItemAttributes.CREATOR)+"\n";
out+="Creator Name: " + workItem.getLabel(WorkItemAttributes.CREATOR)+"\n";
} catch (e) {
out+=e.message;
}
console.log("Creator:" + out);
return out;
}
});
})();
Comments
showing 5 of 8
show 3 more comments