Hi,
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!
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!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
yep, ".created" will call isCreated() in preference to getCreated(). IIRC this is the only place where I've had this problem.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 { it.name == "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)
//issue.setCustomFieldValue(tiempoEntreEllas,CfTMO)
//issueManafer.updateIssue(user, issue, EventDispatchOption.DO_NOT_DISPATCH, false)
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.