Automated e-mail with Table with formatted Dates
Asked by Matheus Takeshi Yano Tako:

Hi Guys,

So I need a little help about a jira automation that sends e-mail.

Basically I try to create a table in a e-mail. Which I already got as the following code:

\<table\>  
\<tbody\>  
\<table border = "1"\>  
\<tr\>  
\<th\>Nome Requisitante\</th\>  
\<th\>Data Envio Recebimento\</th\>  
\<th\>Nome Fornecedor\</th\>  
\<th\>Servi?o/Material\</th\>  
\<th\>Centro de Despesa\</th\>  
\<th\>Centro de Cliente\</th\>  
\<th\>Empresa\</th\>  
\<th\>Joker\</th\>  
\<th\>PO\</th\>  
\<th\>Vencimento\</th\>  
\<th\>Valor\</th\>  
\<th\>N? da Nota Fiscal\</th\>  
\<th\>Forma de Pagamento\</th\>  
\<th\>C?digo de Barras Leg?vel\</th\>  
\</tr\>  
{{#issues}}  
\<tr\>  
\<td\>{{customfield_10167}}\</td\>  
\<td\>{{customfield_10168.format("dd/MM/yyyy")}}\</td\>  
\<td\>{{customfield_10169.substringBetween("1-","2-")}}\</td\>  
\<td\>{{customfield_10170.substringBetween("1-","2-")}}\</td\>  
\<td\>{{customfield_10171.substringBetween("1-","2-")}}\</td\>  
\<td\>{{customfield_10172.substringBetween("1-","2-")}}\</td\>  
\<td\>{{customfield_10173.substringBetween("1-","2-")}}\</td\>  
\<td\>{{customfield_10174.substringBetween("1-","2-")}}\</td\>  
\<td\>{{customfield_10175.substringBetween("1-","2-")}}\</td\>  
\<td\>{{customfield_10176.format("dd/MM/yyyy")}}\</td\>  
\<td\>{{customfield_10177.substringBetween("1-","2-")}}\</td\>  
\<td\>{{customfield_10178.substringBetween("1-","2-")}}\</td\>  
\<td\>{{customfield_10179}}\</td\>  
\<td\>{{customfield_10180}}\</td\>  
\</tr\>  
\<tr\>  
\<td\>{{customfield_10167}}\</td\>  
\<td\>{{customfield_10168.format("dd/MM/yyyy")}}\</td\>  
\<td\>{{customfield_10169.substringBetween("2-","3-")}}\</td\>  
\<td\>{{customfield_10170.substringBetween("2-","3-")}}\</td\>  
\<td\>{{customfield_10171.substringBetween("2-","3-")}}\</td\>  
\<td\>{{customfield_10172.substringBetween("2-","3-")}}\</td\>  
\<td\>{{customfield_10173.substringBetween("2-","3-")}}\</td\>  
\<td\>{{customfield_10174.substringBetween("2-","3-")}}\</td\>  
\<td\>{{customfield_10175.substringBetween("2-","3-")}}\</td\>  
\<td\>{{customfield_10176.format("dd/MM/yyyy")}}\</td\>  
\<td\>{{customfield_10177.substringBetween("2-","3-")}}\</td\>  
\<td\>{{customfield_10178.substringBetween("2-","3-")}}\</td\>  
\<td\>{{customfield_10179}}\</td\>  
\<td\>{{customfield_10180}}\</td\>  
\</tr\>  
{{/}}  
\</tbody\>  
\</table\>

The table is already working as the image attached. But the problem is the date fields are empty in the e-mail.  
![Date Format on Table in email.png](/t5/image/serverpage/image-id/297411i7F1454EFB4F9EEC2/image-size/large?v=v2&px=999 "Date Format on Table in email.png")

I don't get it why the field is empty. I've tried to create a table with only 1 row and it worked. But as soon as I change to 2 or more rows I get the field date empty.  

Can someone help me with this?

Thanks in advance.  

Best Regards.


Answers:
author: Eugenio Onofre
body: Hi [@Matheus Takeshi Yano Tako](/t5/user/viewprofilepage/user-id/5361859)

Have you tried replacing the smartvalue and adding the word "issue" to it? Atlassian has changed the way some smartvalues are accessed a couple years ago and requires the word ISSUE on it.

Please try something as below:  
{{issue.customfield_10168.format("dd/MM/yyyy")}}

Please do not forget to accept this answer in case it helps you resolve your issue as it may help other community members in the future.

Regards,  
Eugenio

comments: author: Matheus Takeshi Yano Tako
body: Hi [@Eugenio Onofre](/t5/user/viewprofilepage/user-id/4992586)

I've tried applying your suggestion, but it didn't work. I got a blanked field in t Date columns.  
I've seen there is a shortDate command that seems good and it worked. The problem is that, I'm from Brazil. And our date format is "dd/MM/yy".  
The shortDate command gives the date as the American format which is "MM/dd/yy".  
I've tried translated the Data to Portuguese (Brazil) and then use the shortDate command, but it didn't work.  
If I could change the ShortDate format to Brazil's format it would work just fine for me.  

I don't know if there's other way to do it. But if there is, please enlight me.  

Thanks for the suggestion Eugenio.  
If you got another suggestion I'll try it and show you the results.  

Best Regards,  
Matheus.


author: Eugenio Onofre
body: Hey [@Matheus Takeshi Yano Tako](/t5/user/viewprofilepage/user-id/5361859)

If you are an instance administrator, you can definitely change the Date Format (I understand the pain, I am also from Brazil!)

In order to change the date format in Jira Cloud, you can go to Cog icon \> System \> Look and feel.

Also, on Cog icon \> System \> General configuration \> Advanced settings, you can change the format of the date picker.

Please do not forget to accept this answer in case it helps you resolve your issue as it may help other community members in the future.


author: Matheus Takeshi Yano Tako
body: [@Eugenio Onofre](/t5/user/viewprofilepage/user-id/4992586)   

As we spoke before. Since I don't have permission to change that configuration, I went to our administrator to see how the date format was configured.  

We saw that the configuration was already adjusted to our desired format which would be DD/MMM/YYYY.

I still can't adjust to that format to my automated e-mail.

Is there another way to configure the date format?

Best Regards,  
Matheus.


author: Eugenio Onofre
body: Hi [@Matheus Takeshi Yano Tako](/t5/user/viewprofilepage/user-id/5361859)

Are the custom fields configured as DATE fields or as text fields?

Regards,  
Eugenio


author: Matheus Takeshi Yano Tako
body: Hi [@Eugenio Onofre](/t5/user/viewprofilepage/user-id/4992586)

The custom fields are configured as DATE fields.  
I assume your ideia would be to use the date fields as text fields and write the date using the brazilian format. Is that correct?  
I'll test that way and comeback to give you a feedback of that suggestion.

Regars,

Matheus.


author: Matheus Takeshi Yano Tako
body: Hi [@Eugenio Onofre](/t5/user/viewprofilepage/user-id/4992586)   

Just to update you. I've tried your suggestion to use the date field as a text field and write the dates in the Brazillian Format. It worked fine as the image below:  
![Date Format on Table in email - Worked.png](https://community.atlassian.com/t5/image/serverpage/image-id/299968i8FA2E8C78B3CD873/image-size/large?v=v2&px=999 "Date Format on Table in email - Worked.png")  
Thanks for helping me with such a bright and simple ideia.

Finally it's gonna be fully automated.

Best Regards,

Matheus.


author: Eugenio Onofre
body: This is great to hear!

Please remember to accept this answer in case it helps you resolve your query so it can also help other community members in the future.

Regards,  
Eugenio


Tags: cloud

jira-service-management

jira-service-management-cloud