Forums

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

JSM Automation: Email containing a table

Marius Fischer
Contributor
January 31, 2024

We would like to send an E-Mail to customers when Changes are approved and will be worked on. Part of that are specific tables agreed upon with the Client.

What is the best way to realize this?

currently the {{issue.description}}/{{issue.description.html}} mails and all different configurations underneath (convert line breaks to html etc.) either don't send the table or create "gibberish".

{adf:display=block}

{"type":"table","attrs":{"isNumberColumnEnabled":false,"layout":"default","localId":"093a1dbf-5720-48d3-9768-d33d9de2534c"},"content":[{"type":"tableRow","content":[{"type":"tableCell","attrs":{"rowspan":2},"content":[{"type":"paragraph","content":[{"type":"text","text":"Change-Typ"}]}]},{"type":"tableCell","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Major-Change"}]}]},{"type":"tableCell","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Minor-Change"}]}]},{"type":"tableCell","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Emergency-Change"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"x"}]}]},{"type":"tableCell","attrs":{},"content":[{"type":"paragraph","content":[]}]},{"type":"tableCell","attrs":{},"content":[{"type":"paragraph","content":[]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Titel"}]}]},{"type":"tableCell","attrs":{"colspan":3},"content":[{"type":"paragraph","content":[{"type":"text","text":")

1 answer

1 accepted

0 votes
Answer accepted
Evgenii
Community Champion
January 31, 2024

Hi, @Marius Fischer 

I think, that you'll need to use list of replaces like:


.replace('{"type":"table"', '<table>')
.replace('{"type":"tableRow"', '<tr>')
.replace('}]}, {"type":"tableRow"', '</tr><tr>')
.replace('}]}', '</tr></table>')
.replace('{"type":"tableCell"', '<td>')
.replace('}, {"type":"tableCell"', '</td><td>')
.replace('{"attrs":{"rowspan":2}', 'rowspan="2"')
.replace('{"attrs":{"colspan":3}', 'colspan="3"')
.replace('{"content":[', '')
.replace('{"type":"paragraph","content":[', '')
.replace('{"type":"text","text":"', '')
.replace('"}]}', '</td>')
.replace('"}]}, {"type":"tableCell"', '</td><td>')
.replace('"}]}, {"type":"tableRow"', '</td></tr><tr>')
.replace('"}]}}', '</td></tr></table>')

 It will generate table like...

<table>
<tr>
<td rowspan="2">Change-Typ</td>
<td>Major-Change</td>
<td>Minor-Change</td>
<td>Emergency-Change</td>
</tr>
<tr>
<td>x</td>
<td></td>
<td></td>
</tr>
<tr>
<td>Titel</td>
<td colspan="3">)
...
</td>
</tr>
</table>

 

Marius Fischer
Contributor
January 31, 2024

Thank you @Evgenii 
for the fast response!

I am not familiar with HTML, so excuse my lack of knowledge. How would i insert sucha  replace list? currently my Automation looks like this:
qwertz.png

Evgenii
Community Champion
January 31, 2024

{{issue.description.html.replace('{"type":"table"', '<table>').replace('{"type":"tableRow"', '<tr>').replace('}]}, {"type":"tableRow"', '</tr><tr>').replace('}]}', '</tr></table>').replace('{"type":"tableCell"', '<td>').replace('}, {"type":"tableCell"', '</td><td>').replace('{"attrs":{"rowspan":2}', 'rowspan="2"').replace('{"attrs":{"colspan":3}', 'colspan="3"').replace('{"content":[', '').replace('{"type":"paragraph","content":[', '').replace('{"type":"text","text":"', '').replace('"}]}', '</td>').replace('"}]}, {"type":"tableCell"', '</td><td>').replace('"}]}, {"type":"tableRow"', '</td></tr><tr>').replace('"}]}}', '</td></tr></table>')}}

Something like this, I think. But this solution looks very weird, I'm sure there is way to make it easier.
For more exact answer, can you give me original text from description? Or screenshot?

Marius Fischer
Contributor
January 31, 2024

This is the table that we would like to send via Mail
asdfg.png


the {{issue.description}} Automation configured as *send as html* as well as *send as plain text* is received in Outlook as:

Change 1: {adf:display=block} {"type":"table","attrs":{"isNumberColumnEnabled":false,"layout":"default","localId":"093a1dbf-5720-48d3-9768-d33d9de2534c"},"content":[{"type":"tableRow","content":[{"type":"tableCell","attrs":{"rowspan":2},"content":[{"type":"paragraph","content":[{"type":"text","text":"Change-Type"}]}]},{"type":"tableCell","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Major-Change"}]}]},{"type":"tableCell","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Minor-Change"}]}]},{"type":"tableCell","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Emergency-Change"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{},"content":[{"type":"paragraph","content":[]}]},{"type":"tableCell","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"x"}]}]},{"type":"tableCell","attrs":{},"content":[{"type":"paragraph","content":[]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Title"}]}]},{"type":"tableCell","attrs":{"colspan":3},"content":[{"type":"paragraph","content":[{"type":"text","text":"Test 2"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Demand-Nr. / Incident-Nr."}]}]},{"type":"tableCell","attrs":{"colspan":3},"content":[{"type":"paragraph","content":[{"type":"text","text":"1234"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"content of change"}]}]},{"type":"tableCell","attrs":{"colspan":3},"content":[{"type":"paragraph","content":[{"type":"text","text":"TestTest"}]}]}]},{"type":"tableRow","content":[{"type":"tableCell","attrs":{},"content":[{"type":"paragraph","content":[{"type":"text","text":"Initiator"}]}]},{"type":"tableCell","attrs":{"colspan":3},"content":[{"type":"paragraph","content":[{"type":"text","text":" Marius"}]}]}]}]} {adf}


and the {{issue.description.html}} *as plain text* :

<p>Change 1:</p>

 

<!-- ADF macro (type = 'table') -->

 

<p> </p>


and the {{issue.description.html}} *as html*:

Change 1:

[nothing else]


is this helpful?

Greetings, Marius

Evgenii
Community Champion
January 31, 2024

Yes, information is enough. I'll check how it can be formatted. As I see, it's not standard, it contains adf tags. I suppose, it's from some sort of forms plugin

Evgenii
Community Champion
January 31, 2024

Sorry, no luck. I tried to change it, but I see, that required information is inside content block, and it's generated not in standard way. Maybe you'll try to disable using forms and make tables by jira standard means?

I made test task with standard table, and saved descriptions in different ways.
{{issue.description.html}} and {{issue.description}} and it works fine

Screenshot_18.pngScreenshot_19.png

Marius Fischer
Contributor
February 1, 2024

Thank you, this solved the issue for me, with the Jira basic table i can generate one in Outlook!

Suggest an answer

Log in or Sign up to answer