Using Atlassian Wiki Markup to Create a Table in the Description
Formatting behavior varies between Jira DC and Jira Cloud.
Jira DC: Typically uses Wiki Markup format
Jira Cloud: Uses Atlassian Document Format (ADF) for rich text
Line breaks (
\n
) are consistently preserved across both Jira DC and Cloud.
A commonly asked question is how to create a table in the description field. To follow along, see this Atlassian wiki markup documentation under the “Tables” heading.
Basic Table
In the script below, I have copied the example from the Atlassian wiki markup documentation and used concatenation to join the string values together. Note the new line character “\n” at the end of each line.
string table = "||heading 1||heading 2||heading 3||\n" +
"|cell A1|cell A2|cell A3|\n" +
"|cell B1|cell B2|cell B3|";
description = table;
The description now looks like this:
Using values from an array.
Let’s say you wanted to make a table, but use values from an array instead. In the example below,
string [] columnNames = "Column 1|Column2";
number [] column1Values = "10|10|10|10|10";
number [] column2Values = "100|100|100|100|100";
// create header
string table = "||" + replace(columnNames, "|", "||") + "||\n";
// add values to table
for (int i=0; i<size(column1Values); i++) {
table += "|" + column1Values[i] + "|" + column2Values[i] + "|\n";
}
// calculate sum of column 1
number column1Total = 0;
for (number column1Value in column1Values) {
// runnerLog(column1Value);
column1Total = column1Total + column1Value;
}
// calculate sum of column 2
number column2Total = 0;
for (number column2Value in column2Values) {
// runnerLog(column2Value);
column2Total = column2Total + column2Value;
}
// add sum at bottom of table
table += "||" + column1Total + "||" + column2Total + "||\n";
description = table;
// runnerLog(column1Total);
// runnerLog(column2Total);
Here is what the description looks like:
If you would like to display wiki markup in a custom field, the custom field must be configured to use wiki-markup using the wiki style renderer. For more details, see this Atlassian documentation.
Related articles
Filter by label
There are no items with the selected labels at this time.