Need a better way to set Work Item Resolution via Wiki Page

Description
DanF
Posts: 1
Joined: Fri Feb 23, 2018 7:23 pm

Need a better way to set Work Item Resolution via Wiki Page

Postby DanF » Fri Feb 23, 2018 7:53 pm

Hi all,

I started developing a page to allow our users to modify the fields of a type of Work Item through a Wiki page. But I had some trouble setting the Resolution.

A Work Item's Resolution field uses the IResolutionOpt class. But I've been unable to find any way to actually make a variable, using Velocity, of this class. I had to resort to referring to a series of dummy Work Items with each of the Resolution field values I need already manually set.

Here's an example of what I did to make this work.

Code: Select all

#set ($resolutionEnum = $sampleWorkItem.getResolution()) ##This work item has the Resolution value I want already set
#set ($foo = $newWorkItem.setResolution($resolutionEnum))


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?

Thank you

ALMighty
Posts: 80
Joined: Wed Apr 27, 2016 10:34 am
Location: Austria

Re: Need a better way to set Work Item Resolution via Wiki Page

Postby ALMighty » Fri Mar 09, 2018 3:17 pm

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. :cry:
---------------------------------------------------------------------------------------------------
Playing a good game is never lame. :D
Image


Return to “Polarion Application Lifecycle Management (ALM)”

Who is online

Users browsing this forum: No registered users and 5 guests