Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


com.onresolve.jira.groovy.groovyrunner for ScriptRunner for Jira Script Listeners option

Oswaldo Peña Perilla
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
Nov 14, 2023

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:

  1. I create the date and time type field
  1. I will go to the Script Listeners option
  1. I choose the Custom listener option
  1. Fill in the fields with the options with a project and the event assign

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)

    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 /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 /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

0 answers

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events