It's all about the answers!

Ask a question

Seeting default value for Workitem custom attribute


m sawires (1462268) | asked Mar 25 '10, 11:05 p.m.
Hello,
I'm creating a custom attribute for a workitem as follow. How can I set its value? Thank you for your help.

IAttribute attribute = getWorkItemClient().createAttribute(
projArea, "Identifier", attributeType, IAttribute.FULL_TEXT_KIND_DEFAULT, monitor);
PermissionContext.setDefault(attribute);
workItem.addCustomAttribute(attribute);
workItem.setValue(attribute, attribute.getIdentifier());

One answer



permanent link
Patrick Streule (4.9k21) | answered Mar 26 '10, 5:33 a.m.
JAZZ DEVELOPER
I'm creating a custom attribute for a workitem as follow. How can I
set its value? Thank you for your help.

IAttribute attribute =
getWorkItemClient().createAttribute(
projArea, "Identifier", "SMALL_STRING", "Test
Attribute", monitor);
PermissionContext.setDefault(attribute);
workItem.addCustomAttribute(attribute);
workItem.setValue(attribute,
attribute.getIdentifier());

Here's the corrected version of your code:

// Create an attribute of type small string
IAttribute attribute = getWorkItemClient().createAttribute(projArea,
"com.yourcompany.attribute.test", AttributeTypes.SMALL_STRING, "Test
Attribute", monitor);

// Express that this attribute is part of the work item
workItem.addCustomAttribute(attribute);

// Set a value for this attribute
workItem.setValue(attribute, "Some value");

If you are interested in configuring default values for attributes,
please take a look at:
https://jazz.net/wiki/bin/view/Main/AttributeValueProviders

--
Regards,
Patrick
Jazz Work Item Team

Your answer


Register or to post your answer.