It's all about the answers!

Ask a question

Get non built-in attribute values from javascript

Marco Delato (512114) | asked Jul 10 '12, 12:24 p.m.
edited Jul 10 '12, 2:55 p.m. by Jared Burns (4.5k29)
How to get Custom Attribute values from Javascript?

In the wiki there is the list of the constants that can be used to get Workitem built-in attributes.

In is shown how to create a custom attribute to store - for instance - UserName. The value of the custom attribute is automatically calculated by the attribute OwnenBy (of the workitem) and can be "Use(d) this id in other scripts that need to identify this particular user"

How to get the value of this new (custom) attribute from other scripts?

Thanks in advance,
Marco Delato

One answer

permanent link
Millard Ellingsworth (2.5k12431) | answered Jul 10 '12, 3:53 p.m.
When you create the custom attribute, take note of the ID value you assign it and use that in the workItem.getValue() call (rather than use one of the built-in IDs defined in WorkItemAttributes.*).

For example, I created a custom attribute named customAttribute1 (a small string) and set its ID value to "edu.millard.customattribute1". To retrieve it in JavaScript, I just used: var customAttr1 = workItem.getValue("edu.millard.customattribute1");

Your answer

Register or 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.