Counting linked requirements in velocity

Description
Harou33
Posts: 10
Joined: Wed Apr 04, 2018 10:40 am

Counting linked requirements in velocity

Postby Harou33 » Tue Apr 17, 2018 2:20 pm

Hi, I have a simple table in Info Page. One of these columns should inlude counting of requirements, which are linked to requirements issue. I wrote something like that:

Code: Select all

#set($query="project.id:######## AND document.title:######## AND type:systemRequirement")
#set($WIs=$trackerService.queryWorkItems($query, "id"))
#set($cnt = 0)
#foreach($wi in $WIs)
  #foreach($link in $wi.getLinkedWorkItemsStructsBack())
    #if($link.getLinkRole().id == "issue")
      #set($cnt = $cnt + 1)
    #end
  #end
#end
$cnt


But it doesn't work and I have know idea why or where the error is. So anyone can help?

Jürgen
Posts: 39
Joined: Tue Sep 12, 2017 1:02 pm

Re: Counting linked requirements in velocity

Postby Jürgen » Wed Apr 18, 2018 11:38 am

I have tried the script with my own project and basically it runs fine.
This concludes to wrong strings for project id, type, document or link role.
Make sure that the document string also contains the space name. You could also try with document.id instead of title.

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

Re: Counting linked requirements in velocity

Postby ALMighty » Wed Apr 18, 2018 2:11 pm

Harou33 wrote:Hi, I have a simple table in Info Page. One of these columns should inlude counting of requirements, which are linked to requirements issue.


Info page you say? There it cannot work, what you need is a WikiPage since a Info Page cannot execute Velocity code like you have posted it (by the way Polarion uses still Velocity 1.4 currently). Check also my post in the thread How to set external links in left navigation bar / shortcuts.xml for the different page types. Polarion help concerning pages says that Wikipages are outdated but ignore that, if fulfills your purpose.

Harou33 wrote:

Code: Select all

#foreach($link in $wi.getLinkedWorkItemsStructsBack())



Please be also aware that getLinkedWorkItemsStructsBack() is not the same like getLinkedWorkItems(), I guess the latter fulfills rather your needs.

Check also my post in the related thread Workitem Query on 2 stages which is also all about getting linked work items. :wink:
---------------------------------------------------------------------------------------------------
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 2 guests