How to parse a table from text field in an issue into a table in an email using A4J

Dave Furlani April 19, 2023

We have a Jira Service Management project that often has tables pasted into a text field.

When using that field in an email action in A4J, the table appears like the confluence wiki mark-up for a table, e.g.

|| heading || heading ||

| text | text |

| text | text |

 

What I'm hoping to do in A4J is parse that into HTML so the table appears correctly in the email that A4J sends. 

Can any one suggest a way?

1 answer

1 accepted

0 votes
Answer accepted
Dave Furlani March 12, 2024

So, turns out there's a .html option, but depending on what's in the table in the field can produce some ugly results with badly aligned text.  

Field output from {{customfield_10347}}

download.png

Output from {{customfield_10347.html}} which the forum won't let me include, looks very vanilla and should just produce a very plain table. Sadly, it doesn't.

 

Which sadly appears in Outlook like this, which seems to be extra line feed chars added as part of the .html option for each pipe char in the original mark-up that displays a table in Jira/Confluence.:

Screenshot 2024-03-13 093448.png

By adding in the .replaceAll I was able to remove the unwanted new lines, and then use a few .replace to change the styling to something more like I wanted 

{{customfield_10347.html.replaceAll("(\n)","").replace("'table-wrap'>","'table-wrap' style='font-family: calibri, arial, sans-serif; font-size: 11px; border-collapse: collapse; text-align: left; vertical-align: top;'>").replace("'confluenceTh'>","'confluenceTh' style='color: #fff; background: #204b87; padding: 5px; height=15;'>").replace("'confluenceTd'>","'confluenceTd' style='color: #fff; background: #204b87; padding: 5px; height=15;'>")}}

 

Dave Furlani March 12, 2024

Wow. Took me a year of distractions to finally get enough time to sort out my own problem. I hope that helps someone one day

Suggest an answer

Log in or Sign up to answer