Velocity – the quick way, to realize small customizings in Polarion.
In this Part, I will explain the basic functionalities of Velocity in Polarion. Additional information about APIs will be introduced in other posts.
First of all: What can I do with Velocity?
- Configure report widgets even more detailed
- Create your own widgets
- Render information dynamically in documents
- … short: Code that I can access the Polarion API with and customize reports & documents.
Where can I use Velocity?
- Script blocks in report pages
- Velocity widgets
- Classic wiki pages
- Classic wiki blocks in documents
- Administration (e.g. Test Execution Form)
I want to show the capabilities of Velocity at the example of a code block in a report page. There you can simply repeat, what I am writing.
Go to Polarion and create a new „Live Report Page“. Then add a new widget of the type „Script – Block“ to it. In this you can write Velocity code and try things.

Attention: You might not be able to use the latest Velocity version here.
For you, I will mention the most important functions:
- Declare variables:
#set($variableInteger = 1)
#set($variableString = „abc“)
#set($variableList = [])
#set($x = variableList.add($e)) - Loops:
Foreach:
#foreach($e in $elements)
doSth
#end

- More Loops
____
How to create a „for-loop“:
#set($start = 1)
#set($end = 5)
#set($range = [$start..$end])
#foreach($i in $range)
doSth
#end

- Conditions: IF / Else
#if($var == „XYZ“)
doSth
#else
doSthElse
#end

- Macros / Functions:
Important: Macros must be defined, before they are called!
#macro(nameOfMacro $variable1 $variable2)
doSth
#end

- Commenting:
## This is a comment - Find out class of an object
By using the attribute „.class“ you can find out, from which class an object is.

8. Important: The Object Factory allows to use things like a Map, although velocity itself doesn’t provide something like that. You can access it in the velocity context via „$objectFactory“. (Might not work in classic wiki content/pages)

I hope this could give you a basic overview of the most important functions in Velocity.
Your Blog has been more helpful than all the Polarion official documentation when it comes to writing code. I am curious does Polarion support Velocity methods, I have been unable to get them to work.
https://velocity.apache.org/engine/devel/user-guide.html#methods
Thanks for a great blog
Hi Chris,
great to hear you like the blog!
If I understand correctly, then the mehods that you find in the Polarion API are exactly that. So yes, Polarion supports methods. Otherwise you wouldn’t be able to do e.g. $trackerService.queryWorkItems().
Best,
Dude