Hi Community
I would like some assistance with scriptrunner - I want to return the Due Date value in a preferred format as currently with Dataplane reports the date format (as displayed) is not ideal.
Currently in Dataplane the Due Date value is displayed as YYYY/MM/DD however several teams want this to be displayed as DD/MM/YYYY instead (like it is in Jira). Dataplane vendor (Arsenale) advised their addon doesn't currently support changing this but suggested a scripted field maybe able to do it.
Essentially I want to create a scripted field that returns the due date value of the issue in my preferred format. I have had a poke around the community forums and appears to be some solutions for customfields, but due date is a system field (and I can't quite work out what to do).
Any help would be greatly appreciated.
Regards, Jamie
Because this is an internet forum, allow me to first tell you that what you want is wrong. yyyy-mm-dd is God's own format that avoids all ambiguity, sorts naturally and is ISO-approved.
But if you really want to, this Groovy code reformats the due date:
import org.joda.time.format.*
DateTimeFormatter fmt = DateTimeFormat.forPattern("dd-MM-yyyy")
fmt.print issue.getDueDate().getTime()
Go to the 'Script Fields' admin section, and create a new Script Field of type 'Custom Script Field', paste that in and preview with an issue that has a due date.
For Groovy scripting, a useful trick is to append '.class' to a known object to find it's type, then google that class to find what methods the class has. I start with 'issue', then find I can do 'issue.getDueDate()', and then google how to format a java.sql.Timestamp.
Thanks @Jeff Turner this is helpful and will do what the users want for their reporting.
Thanks also for your response - I'll give you a pass since its Friday and I can laugh it off. I guess from user's perspective the 'how it is' way is not helpful since Jira formats date fields in our instance the wrong way round but this is why we have scriptrunner to re-format things all the wrong ways :)
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.