How to use javascript to retrieve value of Contributor attirbute
DH Lee (257●8●44●46)
| asked Oct 31 '12, 9:42 a.m.
JAZZ DEVELOPER edited Apr 02 '13, 4:41 a.m. by Ralph Schoon (63.5k●3●36●46)
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 |
2 answers
Ralph Schoon (63.5k●3●36●46)
| answered Nov 01 '12, 5:07 p.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER edited Nov 01 '12, 5:09 p.m.
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 Hello Ralph, Thank you for answer
|
Ralph Schoon (63.5k●3●36●46)
| answered Nov 07 '12, 2:20 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER edited Nov 07 '12, 2:24 a.m.
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; } }); })(); Comments I tested this with 4.0, but I am reasonably sure it would work with 3.x as well.
Hello Again Ralph, Thank you for detailed answer and example. I have studied your code and figured that I was able to retrieve ID / value of fixed (rather pre-existing) attributes. But the problem is that I am not able to retrieve ID / value of custom attribute... Is there anything I need to be aware in order to retrieve ID / value of custom attribute contributor type?
Just to add, if code required to retrieve value / ID of custom attribute (type contributor) is the same, I am suspecting configuration of the attribute might have some issue...
To get the value of a custom attribute use the ID from the process configuration. For example
Hello Ralph, for some reason i did not receive notification for your update...
More note, I am able to retrieve value of other custom attributes except Contributor type. Also retrieving contributor type of none customized attribute works fine...
Udaya Puthuraya
commented Jan 29 '13, 1:17 p.m.
Hi Lee, I have the same issue.
Hi Udaya
showing 5 of 8
show 3 more comments
|
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.