Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

PocketQuery template - handle comma delimited values in a column

Michael Woffenden
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 17, 2021

We have the following template working with a single value in the "Computers" column, such as "C01".

screenshot_4561.png

However, sometimes the Computers column contains more than one computer, such as:

  • C01, C02

and we want each one converted to a separate link.  Some sort of a "for each" within the cell.

Any ideas on how to do this?

1 answer

1 accepted

2 votes
Answer accepted
Michael Woffenden
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 17, 2021 edited

Got it working.  Note that we replace all commas with semi-colons prior to processing with PQ, hence the use of the semi-color in the below code.

<tbody>
#foreach ($row in $result)
<tr>
#foreach ($key in $row.keySet())
#if ($key == "Computers")
<td>
#set ($computers = $row.get("Computers"))
#foreach($computer in $computers.split(";"))
<a href="https://mydomain.com/prefix-$computer">$computer</a>
#end
</td>
#else
<td>$row.get($key)</td>
#end
#end
</tr>
#end
</tbody> 

The Apache Velocity Engine - User Guide was very helpful. 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
7.10.0
TAGS
AUG Leaders

Atlassian Community Events