How to set Priority & Severity using Plain java API
I am using the following code
Identifier<IPriority> iPrio = Identifier.create(IPriority.class,"High");
workItem.setPriority(iPrio);
Identifier<ISeverity> iSever = Identifier.create(ISeverity.class,"Major");
workItem.setSeverity(iSever);
but the above code adds one more entry to the enumeration instead of selecting existing one.
Can anyone tell me what mistake i am doing?
Thanks
Accepted answer
the third post here https://jazz.net/forum/questions/94776/assertionfailedexception-problem-with-getting-the-values-of-attributes shows how to go the other way, (get the human value of enumerations) but uses the right apis to get the values.
so, you would get the list of values for the list of enum entries, find the literal value that matches and use that.
the severity enum looks like this
<code>
<enumeration attributeTypeId="severity" name="Severity">
<literal icon="processattachment:/enumeration/unassigned2.gif" id="severity.literal.l1" name="Unclassified"/>
<literal icon="processattachment:/enumeration/minor.gif" id="severity.literal.l2" name="Minor"/>
<literal default="true" icon="processattachment:/enumeration/normal.gif" id="severity.literal.l3" name="Normal"/>
<literal icon="processattachment:/enumeration/major.gif" id="severity.literal.l4" name="Major"/>
<literal icon="processattachment:/enumeration/critical.gif" id="severity.literal.l5" name="Critical"/>
<literal icon="processattachment:/enumeration/blocker.gif" id="severity.literal.l6" name="Blocker"/>
</enumeration>
</code>
to set "Major" the value is "
so, you would get the list of values for the list of enum entries, find the literal value that matches and use that.
the severity enum looks like this
<code>
<enumeration attributeTypeId="severity" name="Severity">
<literal icon="processattachment:/enumeration/unassigned2.gif" id="severity.literal.l1" name="Unclassified"/>
<literal icon="processattachment:/enumeration/minor.gif" id="severity.literal.l2" name="Minor"/>
<literal default="true" icon="processattachment:/enumeration/normal.gif" id="severity.literal.l3" name="Normal"/>
<literal icon="processattachment:/enumeration/major.gif" id="severity.literal.l4" name="Major"/>
<literal icon="processattachment:/enumeration/critical.gif" id="severity.literal.l5" name="Critical"/>
<literal icon="processattachment:/enumeration/blocker.gif" id="severity.literal.l6" name="Blocker"/>
</enumeration>
</code>
to set "Major" the value is "
severity.literal.l4"
Comments
Thanks a lot. I think i will go with the simple "severity.literal.l4"
works great. Thanks once again
Karthik, for more advanced scenarios you might want to check this post: http://rsjazz.wordpress.com/2012/08/20/manipulationg-work-item-enumeration-values/