Search code examples
workitempolarion

Polarion retrieve Workitem from PObject


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


Solution

  • 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