In some cases, you may have a project where you filter items by a specific Page parameter, but then you decide that you want to load parents above the filtered items.
In this article, we will have a look at one case describing how to succeed in it.
Imagine all work packages in our project correspond to a specific department and there is a Page Parameter "department" that we use if we want to see the work packages for a specific department.
So we create a Page Parameter, then reference to the PP in the Query field and select the value we want to show.
With this approach, we will see the Work Packages as the highest level in the Gantt chart, but we also want to show 2 additional levels of the parent items for the work packages.
To do so, we need to use the Page Script block and Polarion APIs.
You can find all the Polarion classes and methods here: click here
Put the following code into the Page Script:
#set($parentLinkRole = "parent") #set($parents = $objectFactory.newSet()) #foreach($i in $transaction.workItems.search.query("department.KEY:$pageParameters.department.toLucene()").sort(id)) #if( !$i.isUnresolvable() && $i.can().read()) #foreach($p in $i.fields.linkedWorkItems.direct) #set($pItem = $p.fields.workItem) #if( !$pItem.isUnresolvable() && $pItem.can().read() && $parentLinkRole.equals($p.fields.role.optionId)) #set($n = $parents.add($pItem.reference.id)) #foreach($pp in $pItem.get.fields.linkedWorkItems.direct) #set($ppItem = $pp.fields.workItem) #if( !$ppItem.isUnresolvable() && $ppItem.can().read() && $parentLinkRole.equals($pp.fields.role.optionId)) #set($n = $parents.add($ppItem.reference.id)) #end #end #end #end #end #end #set($parentQ = "id:(") #foreach($id in $parents) #set($parentQ = "$parentQ $id") #end #set($parentQ = "$parentQ )") <br> parentQ = $parentQ $!pageContext.put("parentQ", $parentQ)
With this script, we iterate through 2 parent levels and add to the Gantt Chart parents for WIs we got by Page parameter.
And then we put our value to the Query field to present it on the Gantt Chart:
As you can see the Gantt Chart now loads 2 extra parent levels for the selected work items.
In case of issues, please send a message to: support@nextedy.com
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article