Hi,
I created custom scheduled job with ScriptRunner that is checking all our projects and sending out emails to responsible for those projects. An email is basically a HTML table with relevant data for the responsible.
My problem here is that I can't seem to find the solution to format table the way I want. I can add borders, and change the background colors of the table rows and columns, but I cant make the table columns to have fixed width. It always has adjustable size (it takes the size of the text).
Is there a workaround for this maybe? Am I doing something wrong here? Take a look at the "table" part of my code bellow.
if(mapResponsible.get(responsible2.toString()))
{
//style='border:1px solid black'
emailBody =
"<tr>"+
"<td style='border-bottom: 2px solid #e8e3e3; border-right: 2px solid #e8e3e3; width: 500px; overflow: scroll'>" + issueTypeName + "</td>"+
"<td style='border-bottom: 2px solid #e8e3e3; border-right: 2px solid #e8e3e3; width: 500px; overflow: scroll'>${overDue}</td>"+
"<td style='border-bottom: 2px solid #e8e3e3; border-right: 2px solid #e8e3e3; width: 500px; overflow: scroll'>${overdueTime}</td>"+
"<td style='border-bottom: 2px solid #e8e3e3; border-right: 2px solid #e8e3e3; width: 500px; overflow: scroll'>${mutablelink.key}</td>"+
"<td style='border-bottom: 2px solid #e8e3e3; border-right: 2px solid #e8e3e3; width: 500px; overflow: scroll'>${projectNumber}</td>"+
"<td style='border-bottom: 2px solid #e8e3e3; border-right: 2px solid #e8e3e3; width: 500px; overflow: scroll'>${msReviewType}</td>"+
"<td style='border-bottom: 2px solid #e8e3e3; border-right: 2px solid #e8e3e3; width: 500px; overflow: scroll'>${reviewMs}</td>"+
"<td style='border-bottom: 2px solid #e8e3e3; border-right: 2px solid #e8e3e3; width: 500px; overflow: scroll'>${commentFinding}</td>"+
"<td style='border-bottom: 2px solid #e8e3e3; border-right: 2px solid #e8e3e3; width: 500px; overflow: scroll'>" + dueDateFormated + "</td>"+
"<td style='border-bottom: 2px solid #e8e3e3; border-right: 2px solid #e8e3e3; width: 500px; overflow: scroll'>${severity}</td>"+
"<td style='border-bottom: 2px solid #e8e3e3; border-right: 2px solid #e8e3e3; width: 500px; overflow: scroll'>${activity}</td>"+
"<td style='border-bottom: 2px solid #e8e3e3; border-right: 2px solid #e8e3e3; width: 500px; overflow: scroll'>${desription}</td>"+
"<td style='border-bottom: 2px solid #e8e3e3; border-right: 2px solid #e8e3e3; width: 500px; overflow: scroll'>" + url + "</td>"+
"<td style='border-bottom: 2px solid #e8e3e3; border-right: 2px solid #e8e3e3; width: 500px; overflow: scroll; word-wrap:break-word;'>${referenceToDocuments}</td>"+
"<td style='border-bottom: 2px solid #e8e3e3; border-right: 2px solid #e8e3e3; width: 500px; overflow: scroll'>${activityImplemented}</td>"+
"<td style='border-bottom: 2px solid #e8e3e3; border-right: 2px solid #e8e3e3; width: 500px; overflow: scroll'>${responsible_2.displayName}</td>"+
"<td style='border-bottom: 2px solid #e8e3e3; border-right: 2px solid #e8e3e3; width: 500px; overflow: scroll'>${qe_cs.displayName}</td>"+
"</tr>"
mapResponsible.put(responsible2.toString(), mapResponsible.get(responsible2.toString()) + emailBody);
} else // If responsible is not in the list: add responsible, add email body
{
emailBody =
"<table style='max-width: 8500px;'>"+ //style='width: 500px; table-layout:fixed; overflow: hidden;'
"<thead style='background-color: #dddddd'>"+
"<tr>"+
"<th style='width: 500px; overflow: scroll'> T </th>"+
"<th style='width: 500px; overflow: scroll'> OverDue </th>"+
"<th style='width: 500px; overflow: scroll'> Overdue Time </th>"+
"<th style='width: 500px; overflow: scroll'> Key </th>"+
"<th style='width: 500px; overflow: scroll'> Project Number </th>"+
"<th style='width: 500px; overflow: scroll'> MS Review Type </th>"+
"<th style='width: 500px; overflow: scroll'> MS Review </th>"+
"<th style='width: 500px; overflow: scroll'> Comment/Finding </th>"+
"<th style='width: 500px; overflow: scroll'> Due </th>"+
"<th style='width: 500px; overflow: scroll'> Severity of findings </th>"+
"<th style='width: 500px; overflow: scroll'> Activity </th>"+
"<th style='width: 500px; overflow: scroll'> Description of implemented activity </th>"+
"<th style='width: 500px; overflow: scroll'> Findings Link </th>"+
"<th style='width: 500px; overflow: scroll; word-wrap:break-word;'> Reference to Documents </th>"+
"<th style='width: 500px; overflow: scroll'> Activity implemented on Date </th>"+
"<th style='width: 500px; overflow: scroll'> Responsible for findings </th>"+
"<th style='width: 500px; overflow: scroll'> QE-CS </th>"+
"</tr>"+
"</div>"+
"</thead>"+
"<tr>"+
"<td style='border-bottom: 2px solid #e8e3e3; border-right: 2px solid #e8e3e3; width: 500px; overflow: scroll'>" + issueTypeName + "</td>"+
"<td style='border-bottom: 2px solid #e8e3e3; border-right: 2px solid #e8e3e3; width: 500px; overflow: scroll'>${overDue}</td>"+
"<td style='border-bottom: 2px solid #e8e3e3; border-right: 2px solid #e8e3e3; width: 500px; overflow: scroll'>${overdueTime}</td>"+
"<td style='border-bottom: 2px solid #e8e3e3; border-right: 2px solid #e8e3e3; width: 500px; overflow: scroll'>${mutablelink.key}</td>"+
"<td style='border-bottom: 2px solid #e8e3e3; border-right: 2px solid #e8e3e3; width: 500px; overflow: scroll'>${projectNumber}</td>"+
"<td style='border-bottom: 2px solid #e8e3e3; border-right: 2px solid #e8e3e3; width: 500px; overflow: scroll'>${msReviewType}</td>"+
"<td style='border-bottom: 2px solid #e8e3e3; border-right: 2px solid #e8e3e3; width: 500px; overflow: scroll'>${reviewMs}</td>"+
"<td style='border-bottom: 2px solid #e8e3e3; border-right: 2px solid #e8e3e3; width: 500px; overflow: scroll'>${commentFinding}</td>"+
"<td style='border-bottom: 2px solid #e8e3e3; border-right: 2px solid #e8e3e3; width: 500px; overflow: scroll'>" + dueDateFormated + "</td>"+
"<td style='border-bottom: 2px solid #e8e3e3; border-right: 2px solid #e8e3e3; width: 500px; overflow: scroll'>${severity}</td>"+
"<td style='border-bottom: 2px solid #e8e3e3; border-right: 2px solid #e8e3e3; width: 500px; overflow: scroll'>${activity}</td>"+
"<td style='border-bottom: 2px solid #e8e3e3; border-right: 2px solid #e8e3e3; width: 500px; overflow: scroll'>${desription}</td>"+
"<td style='border-bottom: 2px solid #e8e3e3; border-right: 2px solid #e8e3e3; width: 500px; overflow: scroll'>" + url + "</td>"+
"<td style='border-bottom: 2px solid #e8e3e3; border-right: 2px solid #e8e3e3; width: 500px; overflow: scroll; word-wrap:break-word;'>${referenceToDocuments}</td>"+
"<td style='border-bottom: 2px solid #e8e3e3; border-right: 2px solid #e8e3e3; width: 500px; overflow: scroll'>${activityImplemented}</td>"+
"<td style='border-bottom: 2px solid #e8e3e3; border-right: 2px solid #e8e3e3; width: 500px; overflow: scroll'>${responsible_2.displayName}</td>"+
"<td style='border-bottom: 2px solid #e8e3e3; border-right: 2px solid #e8e3e3; width: 500px; overflow: scroll'>${qe_cs.displayName}</td>"+
"</tr>"
mapResponsible.put(responsible2.toString(), emailBody);
if(mapCheck.get(responsible2.toString())){
mapCheck.put(responsible2.toString(), mapCheck.get(responsible2.toString()) + "f")
}else{
mapCheck.put(responsible2.toString(), "f")
}
log.debug(responsible2)
}
And it's also not working when I add width to for e.g. <tr> or anywhere.
Thanks in advance.
Hi kukabgd,
Can I please ask if you are using Jira Server or Jira Cloud as you have marked this answer as Jira Cloud and in Jira cloud, I can confirm that Atlassian does not provide any API's for sending custom emails and that they only provide the Send notification for Issue API which can send a notification when an issue is updated.
If you are using Jira Serv er then I would ask you to update the tags for this post to tag this as Jira Server so that users familiar with Jira Server can advise on this requirement.
Regards,
Kristian
Hi Kristian,
thank you for the hint. You are right, we are using server. I've updated tags. Hopefully now I can get some response to this question.
Regards,
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.