how to get value of custom attribute of type workitem using javascript
Nilesh Patil (17●3●41●50)
| asked May 17 '13, 2:08 a.m.
edited Nov 10 '15, 11:13 a.m. by Ralph Schoon (63.5k●3●36●46)
I have scenario where I need to check value of custom attribute of type "workitem" in javascript. when I executed this script(added script based condition) every time I am getting null value . My code is,
var workitemAttribute=workItem.getValue(CustomAttributeID); console.log("Value of Attribute = " + workitemAttribute); /// Output always shows null (LOG: Value of Attribute=null) Can anybody help me out showing how to get value of custom attribute of type workitem? |
Accepted answer
not all attribute types are available via javascript.
see the section under Only values of the following attribute types can be safely read by and returned from scripts: Ralph Schoon selected this answer as the correct answer
|
4 other answers
Ahh...problem with my fast reading habbit and I assumed you are probably writing a script based calculated value.
Check the Attribute Customization page and there are examples as well as descriptions for all script based attribute customization options. Comments
Nilesh Patil
commented May 17 '13, 6:00 a.m.
HI Indradri Basu, Thanks for the quick response.
|
Hi Nilesh, did you ever get this working? I am facing the same problem...
Comments
Ralph Schoon
commented Nov 10 '15, 11:16 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
Check the Attribute Customization page and there are examples as well as descriptions for all script based attribute customization options.And also read and ideally do Process Enactment Workshop for the Rational solution for Collaborative Lifecycle Management the version for RTC and especially lab 5 in the beginning where the limitations are listed.
Paul Rinaldi
commented Nov 10 '15, 6:35 p.m.
Ralph, I am familiar with script based calculations - I have written a lot of them.
I need to get the value of a custom attribute of type Work Item
The following code returns NULL (doc.initiative is a Work Item attribute)
var initiative = workItem.getValue("doc.initiative");
sam detweiler
commented Nov 10 '15, 6:44 p.m.
hat looks right, make sure it is the actual attribute ID.
|
Ralph, I am familiar with script based calculations - I have written a lot of them.
I need to get the value of a custom attribute of type Work Item
The following code returns NULL (doc.initiative is a Work Item attribute)
var initiative = workItem.getValue("doc.initiative");
I have looked at the webpage that you have referenced and can't find an example with an attribute type of Work Item.
Comments
Donald Nong
commented Nov 10 '15, 6:49 p.m.
The reason you can't find an example is that the Work Item type is not fully supported. Probably the exact reason it does not work for you as well.
It should at least return the UUID and not null, I think. Not that you can do very much with the UUID.
|
Ralph Schoon (63.5k●3●36●46)
| answered Nov 11 '15, 4:56 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
I used the following script - calculated value:
// custom-work-item-calc.js /******************************************************************************* * 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.Calc_WI"); (function() { dojo.declare("com.example.Calc_WI", null, { getValue: function(attribute, workItem, configuration) { var value = "-"; var label = "-"; var exception = "none"; try{ value = workItem.getValue("custom.workitem"); label = workItem.getLabel("custom.workitem"); } catch (e) { exception = "Exception reading the attribute value: " + e; } return "Item:" + "\nValue: " + value + "\nLabel: " + label + "\nException: " + exception; } }); })();The value went into the descriptions. The values were null when selecting the work item for the attribute. The values where correct/contained something, when saving. |
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.
Comments
Hi Nilesh, did you set a dependency attribute as well, changing of which the value of the expected attribute will change ? Try removing the whole calculated value script, save the project configuration and recreate it. Also note the "CustomAttributeID" should be within double quotes in the getValue().
HI Indradri Basu, Thanks for the quick response. What is need of setting dependency attribute? I am writing condition based java script.I want to get value of custom attribute which is of type "workitem". In above my code I have used double quotes but still it is giving null value getValue("CustomAttributeID"). Can you help me how to get value of attribute using java script?