Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

setValue in custom enumeration

How can I set a value in a custom enumeration?

I use this code for example to set the Priority

IAttribute priority = service.findAttribute(projectArea,IWorkItem.PRIORITY_PROPERTY, monitor);

IEnumeration<IPriority> resolveEnumerationPriority = (IEnumeration<IPriority>) workItemCommon.resolveEnumeration(priority, monitor);
List priorities = resolveEnumerationPriority.getEnumerationLiterals();
IPriority priorityLiteral = (IPriority) priorities.get(2);
workItem.setValue(priority, priorityLiteral.getIdentifier2());


But I don't know how to set the value in custom enumeration.
Thanks in advance.

0 votes



One answer

Permanent link
cargne80 wrote:
How can I set a value in a custom enumeration?

I use this code for example to set the Priority

IAttribute priority =
service.findAttribute(projectArea,IWorkItem.PRIORITY_PROPERTY,
monitor);
IEnumeration<IPriority> resolveEnumerationPriority =
(IEnumeration<IPriority>)
workItemCommon.resolveEnumeration(priority, monitor);
List priorities =
resolveEnumerationPriority.getEnumerationLiterals();
IPriority priorityLiteral = (IPriority)
priorities.get(2);
workItem.setValue(priority,
priorityLiteral.getIdentifier2());

But I don't know how to set the value in custom enumeration.
Thanks in advance.



it works basically the same as in the example above, except that you need to load your custom attribute by ID, then use ILiteral instead of IPriority

IAttribute myAttribute= workItemCommon.findAttribute(projectArea, "myCustomAttributeId", monitor);
IEnumeration<ILiteral> enumeration= (IEnumeration<ILiteral>)workItemCommon.resolveEnumeration(myAttribute, monitor);
List<ILiteral> literals= enumeration.getEnumerationLiterals();
ILiteral literal = literals.get(2);
workItem.setValue(myAttribute, literal.getIdentifier2());


--
MikeS
Jazz Agile Planning team

0 votes

Your answer

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

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,938

Question asked: Jul 06 '09, 10:39 a.m.

Question was seen: 4,498 times

Last updated: Jul 06 '09, 10:39 a.m.

Confirmation Cancel Confirm