Forums

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

How to change system field Due Date format in custom emails script runner?

mani@123
Contributor
September 7, 2019

Hello All,

I am trying to correct date format in custom email. I am using below script in the Email template:

Due Date: $issue.dueDate

I am getting this:

Due Date: 2019-09-09 00:00:00.0

I want Just Date like below:

Due Date: 2019-09-09

I with the below scripts none of them is working:

${issue.dueDate().format('yyyy/MM/dd')}

${issue.dueDate().format("dd-MM-yyyy")}

Any help would be greatly appreciated.

Thanks in Advance,

Manikanta

2 answers

1 vote
Tuncay Senturk
Community Champion
September 8, 2019

This one?

 new Date($issue.dueDate).format('dd-MM-yyyy')

Sorry I didn't try before sending.

mani@123
Contributor
September 9, 2019

It is not working as expected. Output is like below:

Due Date: (2019-09-17 00:00:00.0).format('dd-MM-yyyy')

I tried with the below script it worked.

${(issue.dueDate).format('dd-MM-yyyy')}

Thanks a lot for your help!

Like # people like this
1 vote
Tuncay Senturk
Community Champion
September 8, 2019

Hi mani@123 

try $issue.dueDate.format('dd-MM-yyyy')

or

$issue.getDueDate().format('dd-MM-yyyy')

Best

Tuncay Senturk

mani@123
Contributor
September 8, 2019

Hi Tuncay,

Thanks for the reply.

Both the scripts didn't worked. Below is the error in logs for both scripts.

$issue.dueDate.format('dd-MM-yyyy')

groovy.lang.MissingPropertyException: No such property: format for class: java.sql.Timestamp
at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.mail.AbstractSendCustomEmail.constructMail(AbstractSendCustomEmail.groovy:258)
at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail.super$2$constructMail(SendCustomEmail.groovy)
at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail.constructMail(SendCustomEmail.groovy:208)
at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail$constructMail$1.callCurrent(Unknown Source)
at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.mail.AbstractSendCustomEmail.constructMailWithConditionResult(AbstractSendCustomEmail.groovy:246)
at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail.super$2$constructMailWithConditionResult(SendCustomEmail.groovy)
at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail.constructMailWithConditionResult(SendCustomEmail.groovy:190)
at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail$constructMailWithConditionResult.callCurrent(Unknown Source)
at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail.doScript(SendCustomEmail.groovy:157)
Cancel

 

For this $issue.getDueDate().format('dd-MM-yyyy')

groovy.lang.MissingPropertyException: No such property: getDueDate for class: com.atlassian.jira.issue.IssueImpl
 at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.mail.AbstractSendCustomEmail.constructMail(AbstractSendCustomEmail.groovy:258)
 at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail.super$2$constructMail(SendCustomEmail.groovy)
 at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail.constructMail(SendCustomEmail.groovy:208)
 at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail$constructMail$1.callCurrent(Unknown Source)
 at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.mail.AbstractSendCustomEmail.constructMailWithConditionResult(AbstractSendCustomEmail.groovy:246)
 at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail.super$2$constructMailWithConditionResult(SendCustomEmail.groovy)
 at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail.constructMailWithConditionResult(SendCustomEmail.groovy:190)
 at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail$constructMailWithConditionResult.callCurrent(Unknown Source)
 at com.onresolve.scriptrunner.canned.jira.workflow.postfunctions.SendCustomEmail.doScript(SendCustomEmail.groovy:157)

 

Thanks in advance,

Mani

Suggest an answer

Log in or Sign up to answer