Seeting default value for Workitem custom attribute
Hello,
I'm creating a custom attribute for a workitem as follow. How can I set its value? Thank you for your help.
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
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