Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Script Runner -- how do I pull Created Date information from an issue?


This is silly, but I am stumped. I am trying to get the created date for an issue. I have a custom Date Picker Field, that needs to be populated by a date that is derived from the Created date plus x number of days based on some logic.

However -- when I try to get the created date, I get an error that I am trying to cast a boolean (see below screenshot).

I am running Jira 5.2.6, and Script Runner 2.1.11

When I look at 5.2.6 API for com.atlassian.jira.issue.IssueImpl, it seems like I should be able to call created -- or getCreated -- and that 'isCreated' is the boolean?

Any tips much appreciated!

2 answers

1 accepted

3 votes
Answer accepted

You provided your answer :-) Try issue.getCreated(). Sometimes it's not clear for Groovy which method to call...

Ha! You're right. I could have sworn I tried that as well. Maybe I had some weird caching goin on. Anyway, this works:

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.Issue

myissue = "TESTPMGMT-17"
IssueManager issueManager = ComponentManager.getInstance().getIssueManager()

Issue issue = issueManager.getIssueObject("$myissue")

Date Created = issue.getCreated()

I will mark your answer as correct. Thanks for the help!

yep, ".created" will call isCreated() in preference to getCreated(). IIRC this is the only place where I've had this problem.

Me pasa una cosa como puedo restar dos campos de fecha por ejemplo he creado un custom field con valor 25/05/2019 y quiero restarle la fecha de hoy  menos 25/05/2019.

si me pueden ayudar por favor.

muchas gracias.


import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.util.ImportUtils
import com.atlassian.jira.user.util.UserManager
import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.UserPropertyManager

CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issueManafer = ComponentAccessor.getIssueManager()
def userManager = (UserManager) ComponentAccessor.getUserManager()

MutableIssue issue = ComponentAccessor.getIssueManager().getIssueObject('GDI-323')//Cojemos la issue hija

//issue = ComponentAccessor.getIssueManager().getIssueObject()//Accedemos a los componentes de la issue

CustomField cfechaSolicitud = customFieldManager.getCustomFieldObjects(issue).find { == "Fecha de Solicitud" }//Buscamos la label Dato1 dentro del padre

log.error("la fecha de solicitud es: " +cfechaSolicitud)

def valuefechaSolicutud =(String)issue.getCustomFieldValue(cfechaSolicitud)//Cojemos el valor del padre en la etiqueta dato1Origen

def value2=valuefechaSolicutud.substring(8,10)
log.error("El valor de la fecha de solicitud es: " +value2)

def hoy = new Date()

def valuefechaHoy=hoy.dateString.substring(2,4)
log.error("El valor de la fecha de hoy es: " +valuefechaHoy)


CustomField CfTMO = customFieldManager.getCustomFieldObjectByName("TMO")//identificar el campo para el seteo
log.error("El campo TMO se tiene que identificar asi: se debe identifcar asi para el seteo: " +CfTMO)

def tiempoEntreEllas=valuefechaHoy - value2

log.error("Fecha entre ellas: " +tiempoEntreEllas)

//issueManafer.updateIssue(user, issue, EventDispatchOption.DO_NOT_DISPATCH, false)

Suggest an answer

Log in or Sign up to answer

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you