0

I am trying to post a link to a workitem on a wiki page, but my query returns the following result: PObject(WorkItem; subterra:data-service:objects:/default/chili_v2.2${WorkItem}WI-43)

Here is my Code:

#set ( $id = $wi.id)
#set ($query = "project.id:$page.getProject() AND type:process  AND backlinkedWorkItems:$id")

#set ($foundItems1 = $trackerService.queryWorkItems($query, null))

How can i extract the Workitem ID and link to the Item? Or How can i change my query to get directly a link to the Workitem?

I really would appreciate some help. It looks simple, but I can't figure out the solution.

Thanks, Lucas

Lucas
  • 5
  • 2
  • 4

2 Answers2

3

What you have in your $foundItems1 variable is a Java list. Since your query is grabbing only one Workitem based on the id, it's a list with one object; specifically, a Workitem object.

According to the Polarion Java SDK, Workitems have a .getId() method. So to spit out a link to the Workitem on a wiki, you can loop through the list and use the {workitem} directive...something like this:

#foreach($foundItem in $foundItems1)
    {workitem:$foundItem.getId()}
#end
a_whit
  • 46
  • 1
1

When debugging this type of problem in Polarion, it is always useful to examine the class of the objects that cause trouble. You can do this easily like this:

$foundItems1.class \\

It will give you

class com.polarion.platform.persistence.spi.PObjectList 

which is something you can look up in the Polarion API doc. Knowing that it is a list, will help you to find the solution as shown by a_whit.

Some more useful checks might be:

$foundItems1.size()
$foundItems1.get(0).class  ## (works only when size() > 0)
$foundItems1.get(0).getId()
Designpattern
  • 184
  • 10