You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
I have a jira version 6.3.12 and a scriptrunner version 3.0.10.
I am looking to capture in a date and time type field the record of the date the request was assigned.
I am doing it as follows:
I add in the path /home/jira6/atlassian/application-data/jira/scripts my script
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
class SetFechaAsignado extends AbstractIssueEventListener {
Category log = Category.getInstance(SetFechaAsignado.class)
@Override
void workflowEvent (IssueEvent event) {
log.debug "Event: $*{event.getEventTypeId()}* fired for $*{event.issue}* and caught by SetFechaAsignado"
def issue = event.issue
def fechaAsignadoId = "customfield_12102"
def fechaAsignadoCf = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(fechaAsignadoId)
log.debug "Fecha cogida"
def fechaAsignadoValue = issue.getCustomFieldValue(fechaAsignadoCf)
// Obtiene la fecha y hora actual como un objeto Timestamp
def currentDate = new java.sql.Timestamp(System.currentTimeMillis())
fechaAsignadoCf.updateValue(null, issue, new ModifiedValue(fechaAsignadoValue, currentDate), new DefaultIssueChangeHolder())
log.debug "Fecha Creada"
}
}
I run the file with the given name e.g. "Setfechaassignado_5”
I go to a project request that maps the Listener and assign the request to a user and the field value is not updated, the listener does not work.
The log gives me this error2 errors
^
void workflowEvent (IssueEvent event) {
@ line 10, column 25.
Script35.groovy: 10: unable to resolve class IssueEvent
^
class SetFechaAsignado extends AbstractIssueEventListener {
@ line 6, column 1.
Script35.groovy: 6: unable to resolve class AbstractIssueEventListener
org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
2023-11-02 15:04:49,696 ajp-bio-8809-exec-294 ERROR soporteJira 904x68270x1 xvx44c 10.55.24.137 /rest/scriptrunner-jira/latest/scriptfields/12500/preview [onresolve.scriptrunner.customfield.GroovyCustomField] Script field failed on issue: SASF-30, field: fechaAsignadoId
2023-11-02 15:04:49,696 ajp-bio-8809-exec-294 ERROR soporteJira 904x68270x1 xvx44c 10.55.24.137 /rest/scriptrunner-jira/latest/scriptfields/12500/preview [onresolve.scriptrunner.customfield.GroovyCustomField]
I know I'm doing a lot of things wrong but I don't know which one of them is wrong, if it's code, if it's version, etc.
From the console the script works