DanF wrote:I already know how to set a String to a specific IEnumOption based on one of our enumerations. But that doesn't work for Resolution. I need it to be specifically iResolutionOpt or it will not accept the value. Is there a better way to do this I haven't been able to find?
I am afraid there is no other way but nontheless I will tell you what I tried in vein because maybe it helps you to find a solution:What I tried out (as you can see in the code below): I often changed enumeration values of custom fields
by reading the enumeration iteself and then pick the desired option based on the ID, name or whatever field.
I wanted to the same with the Resolution but as you have mentioned, it does not except the enum value I picked because it just a IEnumOption but Polarion wants to have a IResolutionOpt, which is basically just a subclass of IEnumOption. Long story short, invoking the setResolution() method does nothing.
Code: Select all
#set($projectID = "$page.space.projectId") ## getting the project ID
## Getting the Enum:
#set ($ds = $trackerService.getDataService())
#set ($contextID = $trackerService.getTrackerProject($projectID).contextId)
## enter the id of the enum like you do it when it the enum is assigned to a custom field
## THE FOLLOWING LINE MUST BE ADJUSTED. The abbreviation before the -resolution part is the ID of the work item type
## to which the work item belongs in which you want to change the resolution,
## this can be found out in the Administration section of a project -> Work Items -> Enumerations:
#set ($enumtype = $polarionTool.typeFactory.getEnumType("IDofYourWorkItemType-resolution"))
#set ($myenum = $ds.getEnumerationForEnumId(${enumtype}, ${contextID}))
#set ($myoptions = $myenum.getAllOptions())
#* Printing all the enum options: *#
#foreach($option in $myoptions))
$option.id <br> ## printing the id
$option.name <br> ## printing the name
#if($option.id == "Closed") ## just an example, insert the id of the desired resolution
#set($desiredResolution = $option)
<h2>Check, resolution found </h2> ## just a debugging output
<h3> $desiredResolution.id (printed again) </h3> <br />
#end ## end if
#end ## end foreach
#set($sampleWorkItemForResolutionChange = $trackerService.getWorkItem($projectID, "XX-1111")) ## place the id of the work item you want to change or query more than just one with the queryWorkItems method
$sampleWorkItemForResolutionChange.setResolution($desiredResolution) ) ## here the change of the resolution SHOULD happen
I also tried two variations, none of them helped:
.) Instead of just assigning $option to $desiredResolution I tried
#set($desiredResolution = $myenum.
wrapOption( $option.getId() ) )
.) Instead invoking [url]getEnumerationForEnumId()[/url] I invoked
getObjectEnumerationForEnumId()Long story short: I am out of ideas. 